it is very simple after exporting the Cert.p12 and key.p12, Please find below command for the generating 'apns' .pem file.
https://www.sslshopper.com/ssl-converter.html ?
command to create apns-dev.pem from Cert.pem and Key.pem
?
openssl rsa -in Key.pem -out apns-dev-key-noenc.pem
?
cat Cert.pem apns-dev-key-noenc.pem > apns-dev.pem
Above command is useful for both Sandbox and Production.