To listen YouTube with the screen off, you just use Google Chrome, this method should work on all devices (iPhone & Android).
Play YouTube music in the background on Android
Go to the YouTube website within the browser.
Tap the three dots button at the top right of the page and tap desktop side.
Once you have completed the steps above, tap on a video to play it and it will continue to play even after you lock your phone. Note that the first time you lock the screen the music playback.
However, You will now be able to see playback control buttons on your lock screen. All you need to do now is hit the play button and start listening to YouTube with the screen off. Due to the issue of audio copyright I would like to not play the music of the songs in this video.
Next how to play YouTube music in the background on iPhone.
Play YouTube music in the background on iPhone
Open Safari and go to youtube.com.
Now search for the music video you want to listen to. Tap the icon in the address bar. Choose request desktop site from the drop-down menu.
Hit play on your video, then press power button. At this point the music will stop because the video stops playing.
Press power button again and all you need to do now is hit the play button and start listening to YouTube with the screen off.