Thanks @svickers2 . I have resolved the issue by generating a new key and updating it in the config/dynamic_settings.yml file. The LTI is now working correctly.
The Steps involved in generating a new JWT token
1. Open the Canvas console using bundle exec rails console
2. Run the following code to generate the token
key = OpenSSL::PKey::RSA.generate(2048)
jwk = key.to_jwk(kid: Time.now.utc.iso8601).to_json
puts jwk
3. Copy the JSON key and stringify it using JSON formatter.
4. Update the key in config/dynamic_settings.yml in the file.
5. Once the file is updated, restart the canvas service. Now the LTI works as expected in self-hosted in canvas instance.