Update 17/01/2017: Joe Kuhns has written a Safari Extension which adds a PiP button to YouTube videos, as well as Plex, Netflix, and a handful of others. It doesn’t add any additional functionality over what I outline below, but it makes it faster to enter PiP.
There seems to be some confusion about whether Picture-in-Picture, introduced in Safari 10.0 and macOS Sierra, is supported by YouTube videos. I’ve seen a lot of people saying it’s not possible because YouTube uses a custom video player, not the standard one.
Yes, it’s true that the standard video player shows a PiP button in the playback control bar, and that button does not appear in the YouTube player.
But PiP does work on YouTube:
Just right click on the video twice.