in my case i needed to enable legacy providers in the openssl configuration before running php bin/console lexik:jwt:generate-keypair --overwrite.
this link explains how to enable legacy providers :
https://www.php.net/manual/en/function.openssl-pkcs12-read.php#128941