There are no exit formalities in the US.
You can safely travel, and renew your passport while in Pakistan. Your passport is valid until midnight of the date of expiry.
If you have any valid visas on your old passport, it will be returned to you along with your new passport; the old passport is no longer valid for travel - but will only be used to show any endorsements (visas or other stamps) to immigration authorities.
You should make sure you ask for expedited passport renewal (it takes around a week) vs the normal month or so.
Here are the requirements:
- NADRA (digital) ID
- NADRA (digital) ID copy
- Old Passport + its copy
The fee depends on how long and how many pages you want on your passport; and it is deposited at a bank:
For 5 year validity:
- 3000 Rupees normal / 5000 Rupees Urgent (36 pages)
- 5500 Rupees normal / 9000 Rupees Urgent (72 pages)
- 6000 Rupees normal / 10000 Rupees Urgent (100 pages)
For 10 year validity:
- 5400 Rupees normal / 9000 Rupees Urgent (36 pages)
- 9900 Rupees normal / 16200 Rupees Urgent (72 pages)
- 10800 Rupees normal / 21600 Rupees Urgent (100 pages)
You can find the location of nearest office for passports online.