It’s quite simple. We need a certificate in pem format with key and ca certificate. Certificate can be with CA in one file. A command to do everything is:
openssl pkcs12 -export -in cert+ca.pem -inkey private-key.key -out mycert.pfx
In the end, we should enter a password for the pfx file.