All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
It is permissible for a person in a state of Ihraam to put something on his head to protect himself from heat or rain. This ruling also applies to a person outside the state of Ihraam with greater reason. It is narrated on the authority of Umm Husayn that she said, "I performed Hajj with the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, in the Farewell Hajj. I saw Usaamah and Bilaal, or one of them, holding the noseband of the she-camel of the Prophet, sallallaahu ‘alayhi wa sallam, while the other was shading him with his garment to protect him from the heat until he threw the pebbles of Jamrat Al-‘Aqabah." [Muslim]
Commenting on this Hadeeth, Ash-Shawkaani said in Nayl Al-Awtaar: "The Hadeeth implies the permissibility of shading one's head with a garment or something he is carrying, and so on. This is the opinion adopted by the majority of the scholars."
Allaah Knows best.