I have YouTube playing videos all the time with the screen off or using a different app and the audio plays fine. I have it play while I drive and the screen is off. I have a Pixel phone. Maybe I set permissions or settings a certain way to allow that, can't remember.
I do have premium YouTube, I watch a lot of videos so it's super worth it to get rid of ads. Yeah not sure if the background playing feature is part of my subscription.