There is no requirement that either the principal applicant or any dependent applicant be physically present in NZ when applying for a Permanent Resident Visa (see
RV2.5 for all of the requirements). Personally, I wouldn't do it myself, in case I end up stuck outside the country having lost residence status, and would ensure that I travelled back with valid travel conditions before applying onshore.
And yes, it
is possible to get a Permanent Resident Visa or a second/subsequent Resident Visa if you are outside NZ with expired travel conditions (see RV2.5 again for the Permanent Resident Visa, in particular RV2.5(a)(ii), and
RV4.10 for a second or subsequent Resident Visa). I still wouldn't do it myself though.