Praise be to Allah.
The name of Allaah should not be written on these caps, so as to protect His name from being disrespected and so as to free the wearer of any inconvenience, because he may need to go to the toilet wearing this cap, and it may be difficult for him to take if off every time he wants to do that.
The way in which the name of Allaah may be disrespected in this case is that the cap may be worn and taken off and placed on the floor and so on, and it may be affected by dirt such as dust and sweat, or the wearer may do something that Allaah has forbidden and disallowed, such as smoking or backbiting about people, when he is wearing the name of Allaah written on his head.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said concerning the ruling on putting Qur’aanic verses on clothing: If the aim of that is to exhort and remind people, we do not find that in the gatherings where verses of Qur’aan are present (e.g. on the walls), we do not find that they increase people’s piety or awareness of Allaah, rather in some of these gatherings we see that evils are committed, where people smoke and backbite about others and eat their flesh, and the book of Allaah is above their heads, but they are gatherings in which Allaah is disobeyed. End quote from Liqaa’aat al-Baab il-Maftooh (2/54).
And Allaah knows best.