"Which hat is yours?"
Translation:Quale cappello è il tuo?
suo can mean "his" or "hers". It agrees with the thing owned, not with who owns it.
il suo = his/her singular masculine thing
i suoi = his/her plural masculine/mixed/unknown things
la sua = his/her singular feminine thing
le sue = his/her plural feminine things
Suo can mean "yours" because
Lei is the formal singular "you" and it takes all of the trappings of 3rd person singular.