It is generally not recommended to put sunscreen on while in ihram.
The state of ihram is a sacred state that requires Muslims to refrain from certain actions, including applying anything that alters the natural state of the body, such as perfumes, cosmetics, and lotions.
However, there are some exceptions, such as applying sunscreen for medical reasons. If you have a skin condition that requires you to use sunscreen, you should consult with a religious scholar to determine if it is permissible.
It is important to remember that the primary goal of ihram is to focus on the worship of Allah. Therefore, it is best to avoid anything that could be considered a distraction from this goal.
If you are unsure about whether or not you can use sunscreen in ihram, it is always best to err on the side of caution and avoid it.