This tip comes courtesy of YouTuber The Technizer, and as you can see below, it's incredibly simple. Just install the browser, use it to open any YouTube link, and when you leave the app, the audio will keep on playing while you check your email, reply to test messages, or even just turn your phone's display off.
If you're not a fan of Firefox, you can use an Xposed module called YouTube Background Playback to get this same functionality by tricking the YouTube app into thinking you have a YouTube Red subscription, a service that includes background playback.
Otherwise, if you're a non-rooted user, this Firefox method is definitely the way to go. If you want to log into YouTube, it's a lot better to do in Firefox than trusting some shady third-party app built specifically for YouTube background playback. Big thanks to The Technizer for the tip, and you can find more of his videos here.