I have a rough understanding of how to calculate expected challenge rating, but I'm not sure how it works in the case of the innate spellcasting dragons variant.
Consider an Ancient Gold Dragon:
Without innate spellcasting, an Ancient Gold Dragon is CR 24. By my calculations, it has a Defensive Challenge Rating of 25, meaning its Offensive Challenge Rating must be 23 to average out to 24. At CR 24, if you used the innate spellcasting variant, it could learn up to level 8 spells. However, depending on which spells it has, that might raise its CR. In order to be eligible to learn level 9 spells, it would need to be CR 27. One way to do this would be to increase its OCR to 29, which corresponds to average damage of 267 per round for three rounds (after accounting for the dragon's higher than average spell save DC).
I don't know if that's possible, but let's say it is. That would bump the dragon up to CR 27. Would it then be possible for the dragon to learn level 9 spells?