Personally, I try not to. Through many painful years of experience, I've come to the conclusion that anyone that tries to be my friend is only wanting free labor or something. I don't mind helping someone out once in awhile when it's my choice, but I don't want to feel beholden to someone because they're a "friend".
A good and true friend once told me that at the end of your life, if you can fill up one hand when you count your friends, then you're truly lucky. So far, I've got four fingers left to go.
If you just want someone to hang around with, I'd suggest introducing yourself to people you see when out doing the things you enjoy doing. I wouldn't just up and greet them out of the blue, but more subtly after chatting a minute or two so you get a feel for whether you even want to know them or not.
If all else fails, you can always find a chatbot online and pretend it's your friend. There are loads of people out there doing just that. Or else spend a few bucks on whatever equipment you need and literally make yourself a friend. I'm sure there are plenty out there for sale if you're not a really creative person. And then there are imaginary friends, too. Those are probably the easiest and cheapest to make. Though, imaginary enemies are much more fun. Not as fun as real enemies nor quite so rewarding, but nothing in life is perfect.
If nothing else works, then just get a dog.
Hope this helps.