JWT or RSA Signing Key issue

I’m not sure I understand what you mean with “dynamic private key”, if you’re trying to generate JWTs that can be validated in other servers, you should generate the private key once and share it between the servers.

PEM expects the string between BEGIN/END lines to be in a very specific format, you can’t use arbitrary strings of your choosing.

I think what you’re looking for is to use HS256 instead of RS256, which allows the key to be a symmetric shared secret instead of an asymmetric key - in this case, the key doesn’t need to be in PEM format so you can skip the BEGIN/END lines altogether.