I had been trying to use "positive self talk" for years, but still found that I was extremely harsh to myself.
For me, talk wasn't enough. Pairing the talk with physical acts of kindness dramatically improved my self-talk, efficacy, mental stability, and overall sense of well-being.
My methodology looks like this- whenever I do something for myself (even mundane daily tasks like making lunch) I consciously "give" myself the nice thing, saying something kind or reassuring while doing it (ie "I made this for you because I like you", "I put the warmer blanket on the bed, you deserve to be comfortable", "I got this for you because everyone deserves a little treat sometimes"). I have only been doing this a few months and the difference is a very noticeable.
This one is probably only relevant to people who didn't learn positive self-talk growing up, but it was a life-saver for me
I have some advice on the "how":
It is unfortunately common to learn self-injurious patterns. And if you do, it will not necessarily seem odd or extreme to you. Take a few minutes to seriously consider if you regularly do something that hurts or harms you- Do you do exercises that hurt? Do you deny yourself food when hungry? Do you force yourself to work past the point of exhaustion? Do you call yourself names?
How would you naturally feel about someone that did those things to you? Probably not great. If you're finding it hard to feel positively about yourself, you may need to stop hurting yourself, or at least commit to trying to stop, and apologize first.
It may feel silly to apologize to yourself, but it can help immensely. Make it a real apology, too: "I'm sorry I hurt you by ________. That was not kind. In the future I will _______, because you deserve to be treated kindly."
Like any other relationship, the apology won't immediately fix it, but it is a first step. The next step is following through on your commitment and consciously choosing to treat yourself like a beloved friend. Every time you slip up or "have to" hurt yourself in the future, apologize to yourself again, like you would to a friend "hey, I'm sorry I took on more than we can handle. Thanks for working overtime to get it done. In the future, I'll be more careful with our time."
To further repair the relationship, "give yourself" your daily self-maintenance as acts of kindness. For example, instead of mindlessly making food because you have to, consciously make it "for your friend(you)". Say something along the lines of "Here, I made this for you, because I like you :)" like you would to a friend. Try to notice something you do well and acknowledge it. Give yourself a compliment. Give yourself little gifts.
Even in the case of a truly unavoidable hurt, like getting a painful medical procedure, acknowledge the pain and show yourself sympathy: "Oof, yeah, it really sucks that this hurts. Thank you for doing this to keep us safe." It is unfortunately common to instead say to yourself something like "Suck it up! Everyone hurts sometimes- that's life!", despite this being extremely dysfunctional. Imagine saying something like that out loud to a friend, and it becomes immediately obvious: if you talk to yourself like this, maybe you hate yourself because you are being kind of an a-hole