You can either add it to your main openssl.cnf file, or you can copy / create a new openssl conf file ( possibly called openssl-mydomain.cnf )
If you add it to the correct openssl.cnf file - you can use the openssl command as above ( with obviously changing the values for subject, keys etc). If you created openssl-mydomain.cnf then you will need to add -config openssl-mydomain.cnf onto the openssl command when generating the key and a Certificate Signing Request