One way could be to introduce a magical cure or an event that breaks the brainwashing. Maybe a key moment from Hiccup's past triggers his return to normal. Also, the support of his dragon could play a crucial role in restoring his mind.
Perhaps have Hiccup confront the source of the brainwashing and overcome it through inner strength and determination. Or, have his friends and allies stage an intervention to break the spell and help him regain his true self.