I think I remember in an older version of D&D allowing you to change a fire spell into a cold-based spell, or vice versa. In 5E, is there any way to allow you to alter say a Scorching Ray into a lightning or cold-based attack? I thought maybe sorcerer spell points might have done the trick, but I cannot find any rule that would cover it. I'm sure you could design and research a spell for that character during a downtime roleplaying option, but I was looking more for a 'on-the-fly' type option.
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.
With the introduction of Tasha's Cauldron of Everything, Sorcerers have gotten the new metamagic option Transmuted Spell that can do this. This is, as everything else in TCE, optional.
When you cast a spell that deals a type of damage from the following list, you can spend 1 sorcery point to change that damage type to one of the other listed types: acid, cold, fire, lightning, poison, thunder.
Thanks to @Jon Aristotle in the comments, there is also another option from Tasha's, the Scribe Wizards Awakened Spellbook:
When you cast a wizard spell with a spell slot, you can temporarily replace its damage type with a type that appears in another spell in your spellbook, which magically alters the spell's formula for this casting only. The latter spell must be of the same level as the spell slot you expend.
There isn't any way to do in the official rules, however in a new addition to the Unearthed Arcana, WoTC included the Wizard arcane tradition Lore Mastery that has a feature called Spell Secrets that can change the damage type of spells.
Spell Secrets: At 2nd level, you master the first in a series of arcane secrets uncovered by your extensive studies.
When you cast a spell with a spell slot and the spell deals acid, cold, fire, force, lightning, necrotic, radiant, or thunder damage, you can substitute that damage type with one other type from that list (you can change only one damage type per casting of a spell). You replace one energy type for another by altering the spell’s formula as you cast it.
When you cast a spell with a spell slot and the spell requires a saving throw, you can change the saving throw from one ability score to another of your choice. Once you change a saving throw in this way, you can’t do so again until you finish a short or long rest.
Given that this is in the UA and not currently in an official book, you should talk to your DM before using this arcane tradition.
It's also worthy of note that certain spells, such as chromatic orb, also allow you choose the damage type.