1. We sat around the bonfire wearing skirts.

2. Wearing red socks, I walked on the hallway.

3. I ran without shoes wearing yellow socks.

4. I slept during the class wearing a fur coat.

5. I slept during the class while/as I was wearing a fur coat.

(Are they all grammatical? Does #4 mean #5?)

They are fine. And yes, 4 and 5 mean the same thing, but I'd use "while" rather than "as."