If you are a level 20 Wizard who is True Polymorphed into an Ancient Brass Dragon, can you then use the Dragon's Change Shape ability to turn back into a level 20 Wizard, maintaining all your class abilities, but also gaining the dragon's hit points, and various other statistics listed in the text of Change Shape?
No, you can't do this. Change Shape lets a dragon turn into "a humanoid or beast that has a challenge rating no higher than its own".
A level 20 wizard doesn't have a challenge rating. You could turn into the CR 12 Archmage, if you wanted, but you couldn't become any player character, because player characters don't have challenge ratings.
In the spell description for True Polymorph (PHB, 283), it says:
The target's game statistics, including mental ability scores, are replaced by the statistics of the new form.
Having your game statistics replaced by the new form means that the only actions you can take are those specified in the stat block of the creature into which you have true polymorphed. Thus, while you are true polymorphed into an Ancient Brass Dragon, you can no longer use your wizard class abilities, which includes the Spellcasting ability gained at level 1. Thus, while under the effect of True Polymorph, your level 20 wizard has no spell slots, cannot ritual cast and so cannot cast any of your prepared or inscribed wizard spells.
While the spell lasts, you are an Ancient Brass Dragon, with all their stat block, including the Change Shape ability. Part of this reads as follows (MM, 104):
In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.
Class features are not gained. So an Ancient Brass Dragon (including a creature that has been true polymorphed into one) can Change Shape into a humanoid wizard, for example an Archmage (MM, 342). However, since the Archmage's magic is based on being an 18th-level spellcaster, this is a class ability (see MM, 10):
A monster with the Spellcasting class feature has a spellcaster level and spell slots, which it uses to cast its spells of 1st level and higher (as explained in the Player’s Handbook).
And so, the Ancient Brass Dragon that has Changed Shape into an Archmage cannot cast spells. If the dragon had decided to become, say, a Drow Mage (MM, 129), then it could use the Innate Spellcasting but not the Spellcasting (which is a class feature).
Basically, if you want a dragon that has shapechanged into a humanoid to be able to cast spells, they either need to have a magic item or to turn into something with innate spellcasting.
So can you turn back into yourself? If the DM rules that a typical dragon could Change Shape into a specific known humanoid, then yes can turn back into someone who looks and sounds precisely like you, and wears/wields exactly the same clothes and items (while having an Ancient Brass Dragon's "alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores" and ability to Change Shape), but this creature will have no wizard class abilities.
So you could pose as a famous/infamous level 20 wizard, able to generate reactions of fear/awe based on reputation alone, but who would actually be unable to cast a single cantrip without the aid of a magic item (and it better not be one that only a wizard can attune to!).
Ironically, confronted with this sham level 20 wizard, a hostile creature that decided to Dispel Magic at level 9 (or which had a very effective spellcasting check for a lower level version of the same spell) would immediately restore the full powers of the level 20 wizard. A delicious moment of irony.
Since Fizban's Treasury of Dragons came out, you can do this with some dragons from that book, since the Change Shape ability of the dragons there don't require the Humanoid shape you are changing into to have a Challenge Rating and also doesn't take away your class features:
Change Shape. The dragon magically transforms into any creature that is Medium or Small, while retaining its game statistics (other than its size). This transformation ends if the dragon is reduced to 0 hit points or uses a bonus action to end it.
These dragons are:
Yes, you can
When you are a level 20 Wizard, your challenge rating is likely lower than 20, assuming that you don't possess quite a bit of magical gear (meaning really powerful items). You could have a shot at trying to calculate your CR based on the process described in the Dungeon Master's Guide. However, this seems only valid for turning back as True Polymorph will use your level as players technically have no challenge rating.
Hence, you can turn into a CR 20 or lower Dragon. Taking into account the earlier comment about gear, the CR of your new form may even rise a bit but may very well not. In any case, you will be able to turn back into your old self using the Dragon's innate ability to change its form.
While your game statistics are replaced, you maintain the essence of your self, your level. I even remember there being an official discussion where someone mentioned that a level 20 Wizard polymorphing into a dragon wasn't a big deal as even though the dragon now also was a level 20 Wizard, the challenge rating was pretty much unaffected as the dragon is already quite powerful. However, I cannot seem to find the source (I'd appreciate any tips in the comments). So yes, you can turn into a dragon and still be a high-level wizard. You are now merely a dragon wizard who might have some trouble with those somatic components and their claws.
Turning back using change shape will also not replace your class features in any way. You will however loose your abilities that relied on your dragon form as mentioned by the spell. However, you will not be able to turn into a level 20 wizard, you will need to turn into a humanoid of a given race (you can likely choose whatever you were before though). You will gain average stats for all those that won't get replaced by the dragon's.
Now to answer your question philosophically, you never cease to be a level 20 Wizard. First you are a humanoid (Elf, Human, Halfling, etc) level 20 Wizard. Then you are a level 20 Dragon Wizard. Using Change Shape you will again become a humanoid level 20 Wizard.
Short Answer: No, here's why:
The target's game statistics, including mental ability scores, are replaced by the statistics of the new form. It retains its alignment and personality.
Nowhere in the Dragon's statblock does anything mention Draconic Wizard Spellcasting. If I am wrong, Please show me where a CR20 Dragon can Shape Change into a Level 20 Wizard to cast Wish. What Page in what official 5e rule book? I checked, I can't find a single Dragon able to Shape Change into a Spellcasting CLASS, from CR 0 through CR 30, in any official 5e book I am currently aware of, UA or official.
Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.
Sage advice quoted the book when they stated: Spellcasting is a Class Feature.
The (dragon) magically transforms into any creature that is (size), while retaining its game statistics (other than its size).
Meaning your Class would be “Dragon” with a subclass of whatever variety you picked, in this question you asked specifically about “Ancient Brass” subclass of the “Dragon” class.
Since Spellcasting is officially a Class Specific Ability, no you would not be a Level 20 Wizard; you might appear to return to your old form, though you wouldn't be able to cast any spells that specific “Ancient Brass Dragon” couldn't cast.