Click on the castle; on the properties panel on the left, there is a garrison hero; you can set a default one, and then modify it by changing it to the desired hero through this window.
Added 9 minutes later
What I wrote is completely unclear.
On the left, when a city is selected, there are object properties. Among them, there is an item with a link to the hero in the garrison. Ideally, he should already be there. If a hero exists, then go to the hero settings and fill in the items; the link in it will point to the hero himself (the basic one); you can choose another one by clicking on it.