>Causes one adjacent target to fall asleep at the end of the next turn. If the target is still on the field and does not have a major status problem at that time, it falls asleep, and this effect cannot be prevented by Safeguard or Substitute. Yawn will fail immediately if the target is already behind a Substitute when the move is used.
Since Yawn is a two-turn move, the following could happen:
If the opponent uses Substitute, and you use Yawn in the same turn, then Yawn will fail altogether.
If Yawn and Substitute is used in different turns (maybe using Substitute to defend yourself off Yawn) then Yawn would still hit the Substitute.
Does that make sense??? :3
Hope I helped. :)