You could use a mana shield based ability with negative mana per point of damage
or you could do in 2 ways with triggers :
1- //unit is attacked
//unit type of attacked unit = ( your unit )
//unit : set mana of attacked unit to [mana of attacked unit+X
2- you will need to create 2 triggers, the first one creates an event for the second one
--Trigger 1 --
//unit enters playable map area
//unit type of triggering unit = ( Your unit )
//trigger :add event to trigger 2 - triggering unit takes damage
--Trigger 2 --
//[no event]
//[no conditions]
//unit : set mana of triggering unit to [mana of triggering unit+damage taken]