we can say for example “I’d like to have a brother, but I don’t have anyone”. But how would we say it with a pet for example “I’d like to have a pet, but I don’t have…”?
***** NOT A TEACHER *****
I would be more comfortable saying “I’d like to have a brother, but I don’t” or “I’d like to have a brother, but I don’t have one.”
I believe that you could use this same pattern when referring to a pet.
In my opinion, the word “anyone” does not fit comfortably in your sentence.
P.S. “Anyone” could be used in a sentence like this:
He is very sad and lonely. He is all alone in this world of 7,000,000,000 people. He doesn’t have anyone. (That is, no family members or friends.)