Hello! The phrase that I would use to express what you want to say with your example is:
2. I don't like being on my own. I prefer being with other people.
That doesn't mean that the expression "with myself" doesn't exist or is wrong, it's just used a bit differently. For example:
"I'm happy with myself." means you are happy with who you are.
"I'm struggling with myself." means you are having inner problems or dilemmas, with your own thoughts, feelings, etc.
In fact, if you were to say the first part of the first sentence you proposed:
1. I don't like being with myself.
It would mean something more along the lines of "I don't like myself". It wouldn't mean "being alone" as your intention was, if I guessed correctly.
If you wanted to use an expression to say "alone" that used the word "myself", you could say:
"I don't like being by myself."
This would be the equivalent of saying "I don't like being on my own." or "I don't like being alone."