By default dragons are not innate spellcasters, but they can be
The starstat blocks of the dragons in the Monster Manual don't have innate spellcasting, but there is an explicit variant called out in the MM to give any age of dragon spellcasting:
VARIANT: DRAGONS AS INNATE SPELLCASTERS
Dragons are innately magical creatures that can master a few spells as they age, using this variant.
A young or older dragon can innately cast a number of spells equal to its Charisma modifier. Each spell can be cast once per day, requiring no material components, and the spell’s level can be no higher than one-third the dragon’s challenge rating (rounded down). The dragon’s bonus to hit with spell attacks is equal to its proficiency bonus + its Charisma bonus. The dragon’s spell save DC equals 8 + its proficiency bonus + its Charisma modifier.
If your DM allows it you can True Polymorph into one of these variant dragons that can cast spells.
That being said, innate spellcaster monsters don't use spell slots to cast their spells. As a result you still won't be able to use your classes Spellcasting feature while True Polymorphed. This is due to this restriction in the True Polymorph spell:
The creature is limited in the actions it can perform by the nature of its new form, and it can't speak, cast spells, or take any other action that requires hands or speech, unless its new form is capable of such actions.