Have you ever seen a computer-controlled ally stay in a town (so they aren't visible)? I haven't, so I doubt that would work. :)
Why? And if you set "add" a hero to a castle in the editor, will he (the hero) be there? If so, he will only stay there until his turn, i.e., while the red player (human) is moving. Does this possibility exist, or am I mistaken?