You teach them the same way you learned. Watch what is happening around you and possibly react similarly.In heavy traffic which is slow moving or stationary you cannot move to the correct side (left) if it is blocked by a line of vehicles. Emergency service vehicles tend to position themselves making it clear they intend to drive between the two lanes. In less congested conditions no problem moving over.Why would you not merge to the left as required by law? Much safer for all. I see cars every day in the median pulled over by the police and think, no common sense to not merge and pull over on the correct side.
Irrespective of which way you react how do you teach a self driving system to recognise an emergency vehicle wants to get past?