1. Saying hey, the foreigner walked toward me.

2. The foreigner walked toward me, saying hey.

3. The foreigner, saying hey, walked toward me.
(Are they all grammatical?)

4. When I was given the mug, I felt happy.
4-2. Given the mug, I felt happy.

5. Because it was written in English, the book is hard to read.
5-2. (Having been) Written in English, the book is hard to read.

6. After the window was opened, the boy came in.
6-2. The window being opened, the boy came in.
6-3. The window opened, the boy came in.
(Are they all grammatical? Can we omit 'being'?)

7. As the door had been opened, the boys could enter the room.
7-2. The door having been opened, the boys could enter the room.
7-3. The door opened, the boys could
enter the room. (Are they all grammatical? Can we omit 'having been'?)

4-2, 6-3, and 7-3 are incorrect. Don't use them.

5-2, 6-2, and 7-2 are all awkward. It's best not to use them, but not errors if you do.

1, 2, 3, 4, 5, 6, and 7 are all correct.