You can basicly use abuse the IssueOrder jass natives to check if an ability is on cooldown. They will return false if the ability can not be cast (but that could also be because of mana cost or an invalid target, so you need to catch those cases aswell).
You can instantly order the unit to stop after that to prevent the unit from actually casting that ability (and triggering the cooldown/manacost).
However, keeping track of the cooldowns via timers is probably the better, less bug-prone solution.