Old tutorials use genrsa and ecparam -genkey, one command per key type. genpkey covers all of them, and it writes the standard PKCS#8 format.
Pick the algorithm and, where needed, an option for size or curve:
openssl genpkey -algorithm ed25519 -out ed.key
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ec.key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out rsa.key
Every file starts with -----BEGIN PRIVATE KEY-----. To see what you made, run openssl pkey -in ec.key -noout -text; it shows the key type and size.
For TLS certificates I would pick P-256: small, fast, and accepted everywhere. Ed25519 is great for signing files and for SSH, but browsers and public CAs do not support it for TLS certificates yet. RSA 2048 is still the safest choice for very old clients, and 3072 bits gives more margin.
The key is written without a passphrase, readable by anyone with access to the file. Run umask 077 first or chmod 600 afterwards, or add a cipher option like -aes256 to encrypt it. Some old software only reads the traditional BEGIN RSA PRIVATE KEY format; openssl rsa -in rsa.key -traditional converts it for those.
Further reading: OpenSSL: openssl-genpkey, OpenSSL: openssl-pkey