When I cast a creature with an ability that costs 2 mana to gain hexproof.Can I activate its ability as I'm casting it ?
The only kind of abilities you can possibly activate during casting are mana abilities.
Even if you could activate arbitrary abilities, you couldn't activate its ability because that ability (like most) can only be activated when the object on which it resides is on the battlefield. From the time you start casting the creature until it resolves, it's on the stack.
Finally, hexproof (like most static abilities) only work when the object on which it resides is on the battlefield, so even if he spell had hexproof (e.g. Ascended Lawmage being cast), it wouldn't have any effect whatsoever.
Really depends on what you mean, a real example would help a lot.
You can respond to a spell on the stack by activating an ability, yes (assuming there is no timing restriction and that the spell doesn't have Split Second). But you can't activate the ability of the spell itself while it's not in play and still on the stack. It means that you can't give your spell hexproof (and that doesn't make any sense anyway) to prevent countermagic for example.
Each players receive priority before each elements of the stack resolve. Every time you receive the priority, you can do things as long as you respect timing restrictions. But you can't activate an ability during the resolution of a spell (you can't split the spell in two even if it has 2 sentences). For example, you can't activate Elixir of Immortality during the resolution of Brainstorm (shuffling your deck after you draw only 1 or 2 cards).