It's not the easiest thing in the world to explain, but basically - you're going to have a spell book ability called "Hero Abilities" that takes the slot the usual "hero abilities" button does (this means none of your heroes will have any hero abilities). You will then give this spell book as many spells as you need. These spells will all be dummy spells based of channel with different spellIDs. They will have no target and be self-cast (make sure to check "visible" in channel too).
Then you'll need a trigger for each spell. Events would be "a unit begins casting a spell" Conditions are "spell being cast = ability A, player has greater than 1 lumber*" and actions are "IF / THEN / ELSE: IF Hero does not have ability A; THEN give Hero ability A; Else, raise level of ability A for Hero"
*lumber is the common 'hero skill points' mechanic but you could also trigger this without using lumber using variables for a player
*to do this system, all of your heroes will use "unit abilities" that will be leveled via the above triggers
I'd give you a way to do this with some greater detail but
A) I wouldn't be surprised if there wasn't already a system like this ready for download. You should look around and see if you can't copy and paste a system like this already made for you into your map.
B) I've outlined what needs to be done, you only need a few triggers but it can be confusing if you don't know what you're doing.