Picture-in-picture (or PiP) is available for iPad users since iOS 9 and Apple has enabled it on iPhone this year with iOS 14. However, YouTube has never supported this feature, which allows users to watch videos while using other apps. This might change now as YouTube has started testing the native picture-in-picture feature in its iOS app.
According to some reports on Twitter, picture-in-picture is slowly being rolled out to some users with the latest version of the YouTube app for iOS. Other reports say that the feature is only working with a few videos, which may suggest that YouTube is still properly implementing PiP.
9to5Mac was able to confirm that the feature is indeed being tested with a small group of users.
Once you have the picture-in-picture enabled, it works just like in any other app that supports it. You can start playing a video and then close the app to continue watching it in a smaller window. The video floats over the iOS home screen or any other app you are using.
Here you can see a video of the picture-in-picture feature working on an iPad: