Is it helpful to wear a scarf as a mask while sleeping?

Don't recommend. The reason this is not recommended is that a scarf is long and can actually loop around your neck and cut off your airway.