There's a very interesting article on exactly this topic. My explanation below is a brief summary of said article.
同じ has two meanings:
- (Meaning 1) Among two or more things, a specific aspect is seen to be equal. For example, 「AとBは同じ大きさだ」.
- (Meaning 2) One thing only is referred to as being the same. For example, 「毎日同じ靴を履いて外出する」.
一緒 can be used interchangeably for Meaning (1) above, but not for Meaning (2).
All your sentences are examples of Meaning 1, wherein two things are compared and found to have an equal aspect (That+This, Same meaning/Me+You, Same day off/Hanako+Me, Same class).
For Meaning (1) you can have sentences like 「あなたの映画の好みは、私と一緒だ」 or 「あなたの映画の好みは、私と同じだ」. However, 一緒 has additional usages which differentiate it from 同じ. For example, it is used to mean 'doing the same thing', referring to actions or behaviour. Sentences which use 一緒に including other people use that meaning (一緒に映画に行きませんか？). It can also be used to indicate that two events happen at the same time (クリスマスと誕生日を一緒にお祝いする), or putting things together (袋に一緒に入れる). For these additional meanings, 同じ cannot be used interchangeably, only for Meaning (1).