Yes, Apple's Face ID is designed to support hats, sunglasses, scarves, glasses, and contact lenses. Face ID also adapts to changes in your appearance, such as growing facial hair and makeup.
Face ID on the iPhone 12 and later also supports mask wearing. In this case, Face ID must be configured with the mask option enabled.
Because Face ID depends on the area around the eyes when wearing a mask, glasses must also be configured under Settings -> Face ID & Passcode
if a mask is to be worn. While most sunglasses normally work with Face ID, they are not supported while wearing a mask.