DM's call, with a bias towards "You only get one attack/spellcast per provoke."
Setting aside the issue of how you get a hydra who can cast spells as an opportunity attack, it appears that the hydra can only opportunity attack with one head at a time. I know Crawford is no longer a strong rules authority, but his feedback on the matter at least seems like it would be pertinent.
In this twitter post, in response to the following question:
@JeremyECrawford Mr. Crawford, I'm confused about Reactive Heads. If a
player provokes an OA from a Hydra, can it atk them with every head?
he gave this answer:
A hydra can have more reactions than normal, but it doesn't change how
an opportunity attack works: one attack per opportunity attack. #dnD
While there has been some confusion on interpretation of this tweet, it seems pretty clear to this poster, at least, that if he'd meant "the hydra can totally attack with every one of its heads in response to a single provocation", it would have been worded differently. Additionally, this brings it in line with the hydra behaviors from earlier editions, where the hydra was able to make a great many opportunity attacks, but only once per provoking event.
By this interpretation, then (which is reasonably well-supported from a reading of the text), you would only get one attack or spellcast regardless.
Now, you may reject Mr Crawford's analysis of things. His tweets are not an official source, after all (or at least, not any more). At that point, the needle swings back to "it's not clear". 5e has by design included a number of places where the rules are not entirely clear, with the intent and expectation that when such things arise, they are DM's call.
So, since War Caster is replacing opportunity attacks, and you (probably) only get one of those at a time, the best available answer (outside of DM adjudication) is: the War Caster Hydra can use one head, to either make a single attack or cast a single spell
Of course, that still leaves you with the challenge of finding an attack spell that the Hydra can actually cast, given the issue with Hydra being incapable of performing Verbal components. Perhaps you have three levels of sorcerer with the right sort of metamagic?