Generate rsa private key:
openssl genpkey -algorithm RSA -out c-rsa-priv.key -pkeyopt rsa_keygen_bits:2048

Extract the public key from the private key
openssl pkey -in c-rsa-priv.key -pubout -out c-rsa-pub.key

Encrypt the file using the rsa pubkey
openssl pkeyutl -encrypt -pubin -inkey c-rsa-pub.key -in plaintext.txt -out c-enc-rsa.txt