Start limiting your time on it. I personally stop watching or using media (Facebook, YouTube, even TV) completely for a while when I feel a pull/addiction to it and then I limit how much I use it when I start to use it again. I time myself to be on Facebook for 10 minutes etc. I replace the behavior with something I feel good about doing/achieving like meditation, cleaning/yard work, learning a skill, going for a walk, being more present for the people or even pets in my life, journaling etc.
I think most addictions stem from them being used as an escape from your own feelings, as when you feel sad or angry it's very easy to use these things to make yourself feel better and distract yourself. The next time you feel yourself compelled to watch YouTube, try meditating or any other method to let those emotions out before you let yourself watch a video.
I am actually dealing with the same addiction. When I am supposed to do homework or working out I just go down the rabbit hole of YouTube and even read/reply comments 😔
Make sure you stop autoplay in the settings, so it doesn't just keep on running new videos that you may or may not like. Also, in Android phones, you can restrict your time on any of the apps. So you could set your YouTube timer for however long you feel is an appropriate amount of time, and maybe try to shorten the time over a span of weeks or months. And don't forget to ask others to help you, to be nice to yourself whether you succeed or not each day, and to celebrate your victories. Good luck!