A Japanese research team showed that dogs can yawn as a sign of sympathy and will be more likely to yawn if someone familiar to them yawns.
25 dogs consisting of pitbulls, papillons, and poodles were involved in this study. The study had dogs watch their owner yawn and compared the reaction to when the dogs watched the experimenter (someone unfamiliar) yawn.
The result was that dogs were more likely to yawn back if they saw their owners yawn. The study authors conclude that this is a indicator that dogs yawned because of the emotional connection that they had to their owners, much like we humans will yawn if we see someone we know yawn.
The study authors also measured the dogs' heart rates to make sure the dogs were not yawning because of distress, which other studies have shown. The dog's heart rates didn't increase when they yawned in this study, which shows that the yawning was not due to anxiety or distress.