Yes you can, if you access YouTube through Safari. Open YouTube in Safari, ask for a desktop version, find any video you like and start playing it in Safari. When you dim the screen with the power button, the sound will stop. Now simply wake up the screen and you will see the play/pause, etc. control menu. Press play and the sound will pick up from where you left it. Now you can dim the screen again with the power button and the sound will continue with the screen switched off. 🖐
This should also work in iOS 13 and possibly 12 too.