My Pakistani passport expires less than a month from now. I understand
that some countries only let people in if their passport is valid for
six months or more. Will I be able to enter Pakistan on a passport
that is about to expire?
Yes. Your passport is valid till the midnight of the date of expiry; and as long as you pass immigration control (at Pakistan) before that, you are okay. Pakistan will not deny you entry even if your passport expires while you are waiting in line for immigration - as you are Pakistani citizen. They may take you aside and have to file some paperwork, but you are guaranteed entry.
Also, travelling back to Pakistan is likely to involve transiting
through some other country. Does the six-month rule still apply to
people returning to their country of citizenship?
No, transiting countries care that you have proper documents/authorization. That means, you need to make sure that if you need any transit visas you have procured them before your trip.
Other than that, they only care that your passport and any other documents are valid for the purpose and length of your journey.