To keep it simple with a single command to convert the .PEM format file to .p12/.pfx we can use the below information.
$ openssl pkcs12 -export -in domain.pem -out domain.p12
It will ask you to enter the export password (twice for confirmation).
It's up to you to choose to enter the password or keep it empty (just press enter) based on the use case what you have.
Hope this helps you to convert the certificate format and use in your application or server.
Request to send your comments and feedback to firstname.lastname@example.org