In Dota 2, you can deny allied creeps and towers, but is it also possible deny an allied hero? If so, how is gold assigned to the enemy team?
Yes, its possible to deny heroes, but only under certain circumstances:
Friendly heroes can only be denied when they are under certain sources of damage over time, such as Doombringer's Doom. You cannot deny a hero who's low on health but not taking DoT.
How is gold assigned to the enemy team:
Denying a hero will prevent the enemy from gaining any experience or gold from the kill, but your ally will still lose gold from dying.
To deny a hero:
Most heroes can only deny a friendly hero by attacking them manually (one exception to this is Tiny, who can deny any friendly unit using Toss as long as they have low enough health).