If your phone has an AMOLED display, it doesn't waste any battery to power black portions of the screen. This is because the individual pixels that make up an AMOLED screen emit their own light, which means the backlight you'd find behind a traditional LCD screen is not present. In other words, showing a full-screen black image on an AMOLED phone is like turning your display completely off.
With that in mind, the development team at Neximo Labs created an app that should save you a lot of battery while playing music on YouTube (or other services that don't let you stream audio with the screen turned off without paying), as it simulates a turned-off display by simply overlaying an all-black screen on top of any app. But again, this only applies if you have an AMOLED device.
The app that will save you tons of battery while playing music from YouTube is called Blackr - AMOLED Screen Off, and it's available for free on the Google Play Store. All "pro" features are free, so don't let that confuse you any, but you can still donate to the developer from within the app if you enjoy their work.
Open the app, then enable its main functionality with the switch at the top of the screen. From here, if you're using a device with on-screen navigation buttons, make sure to tap the three-dot menu button in the top-right corner, then head to "Options" and enable the "Hide Navigation" setting.
Aside from that, you can opt to enable a floating icon that you can use to turn the black screen effect on. By default, the black screen will show the current time, but you can disable that in the Active Mode section if you'd like. Then, if you head to the "Settings" option at the bottom of the screen, you can tweak a few more options, so make sure to poke around in here to get a feel for all of the options.
Once you've got everything set up to your liking, it's really easy to save battery while listening to music on YouTube. Anytime you need it, just tap the ongoing notification from Blackr, and your screen will instantly go black. But because the screen isn't really "off," the music will keep on playing — the only difference is, you won't be wasting battery life since your AMOLED screen won't be drawing any power.
Become an Android phone expert with our Ultimate Guide to Android eBook.