I'm a nerd, I have nerd friends (both genders). Supposedly, we can't get away with being nerds. We paid a "social price" for being true to ourselves. But we basically didn't give a shit about what other people thought. After some time, people get used to you being you, and the price you pay, becomes lower.
So yes, men can get away with plenty of things as long as they aren't commiting a crime. There would be a price to pay, but they can do it. The price men pay for doing those things that you say they can get away with is to not being take seriously as if they were women. Yes it sucks, but it is a choice. And by the way, it also sucks for women to not be taken seriously.
There is also a cultural spin. I mean, where I live, men have friends (both male and female). It is considered normal to hugh your friends. Two men hughing is normal. So if you feel lonely, the first step is to change and talk more to your friends. And look for other men who are willing to do the same.
People keep saying things like "men should be courageous", "men should be brave", "men should be fearless", etc. Well, going against the tide, being your true self and taking the risk of people disapproving on you for not fitting in or not complying with the expected roles takes courage. Those nerds who were at the lower social ladder at highschool, enjoyed good friendships and remained loyal to each other. We didn't feel so lonely because we had each other. We still are friends even if now some of us have families, jobs, etc.
So my advice is that you look around you and if some women in your live are doing well in an area that you want to improve, use them as a model. You don't need to copy everything they do, only the things related to that area. And you can adapt behaviours and strategies to fit you better.
Remember, you can't be liked by everyone, so focus on becoming someone who you like. And if you want to avoid loneliness, reach out for people. Then see who answer back and keep that people who answer back close. If a "friend" reacts badly to you wanting to share something (feelings or ideas), maybe is not a good friend. I mean, the friend might disagree or not like what you say. If you do drugs, a good friend might not like (rightfully) or if he thinks you are making a huge mistake that would hurt you. But at the end of the day, you know who you can count on. Start there. And tell them that they can also share whatever they want with you, no judgment.
It is up to you and I'm not saying that it would be easy. But once you take the first steps, you'll lose fear and it would become way easier to keep doing it. Kind of receiving a punch. It hurts, but once you have recived one, you won't fear them as much because you do know what to expect.