There is currently1 no way to do this in the rules.
If you’re trying to avoid damage resistance, there is a feat that can help you: Elemental Adept. It lets you choose an elemental damage type, and spells that deal damage of that type ignore resistance. So, for example, you could take Elemental Adept (Fire), and your Scorching Rays would ignore fire resistance.
If you’re trying to get around damage immunity, or exploit damage vulnerability, then you’re out of luck. The only solution that currently exists is to pick spells with different damage types so that you always have the one you need.
Of course, this is D&D, so you could always ask your DM if they’re willing to houserule something that would let you swap elements the way you want to. A metamagic option for the Sorcerer makes the most sense, but balancing it could be tricky. A Warlock invocation might also work here, but balancing it would be even harder.
1 Current published materials: DMG, PHB, MM, Elemental Evil Player’s Companion.