Some characters are loved precisely because they're arrogant, narcissistic, sociopathic assholes. They don't alienate the audience by virtue of being charismatic, entertaining, or (even better) both. There's a TVTropes article called Awesome Ego:
This is the type of narcissist who constantly rants and raves about how mind-blowingly awesome they are, and the fans agree with them.
How do you make this kind of characters work?
Justify their massive ego with extraordinary skills.
You can (but don't have to) add some redeeming features, to round them out. This kind of characterization works best in more serious stories. Here's some examples, all taken from TVTropes:
Tony Stark in the MCU:
A brash-but-brilliant engineer who shows off his colossal wealth with
luxury, world-class accommodations and specialized expos, is the
in-universe poster child for playboys, talks a big game to everyone he
meets, and always has a swagger to his stride... also has a two-sided
Dark and Troubled Past, suffers from PTSD, carries around an
Inferiority Superiority Complex and a guilt complex, cares deeply for
his friends and teammates, is a father figure to his protege
Spider-Man, would sacrifice himself for the greater good, and is
terrified of not doing enough to keep the world safe. He's just very
good at hiding it.
Walter White in Breaking Bad:
Possibly the only reason anyone roots for Walter White later on in
Breaking Bad. He may Kick the Dog several times an episode at least,
but he throws out awesome moments and bombastic speeches just as
frequently. The best example of this would be his exchange with (and
subsequent dominance over) rival drug dealers from Phoenix at the
beginning of "Say My Name".
Dio Brando in JoJo's Bizarre Adventure:
Dio Brando is a good contender for the biggest Jerkass in manga
history, and it shows... but he's so charismatic, it doesn't really
See this scene for an example of what they mean.
Make them so narcissistic/sociopathic that the reader can laugh at them.
Inflate their ego to the point that it's so over-the-top, that you're more likely to laugh at how absurd their actions are, than be alienated by what they're doing.
Dennis from It's Always Sunny In Philadelphia:
The most sociopathic of the characters, Dennis is abrasive,
narcissistic, self-absorbed, manipulative and callous. Much of his
inflated ego is perpetuated by his Ivy League education at the
University of Pennsylvania where he minored in Psychology.
Everyone in that show is a sociopath, but he's the worst of them. He's the last person to be friends with, but his antics are quite entertaining. See this scene where the main characters go to a therapist, or this scene where he goes berserk because someone slighted the "Golden God's" (that's what he calls/considers himself) car.
Eric Cartman from South Park:
Yes, he is a smarmy, self-serving, thoroughly sociopathic bully who
has no qualms about doing literally whatever he wants, damn the
consequences. But one side effect is that he's so completely fucked up
that he can occasionally be called upon to get everyone else out of
catastrophic situations when all else seems lost — and he does so in
ways so ruthlessly efficient and imaginative, only he could have ever
come up with them. In The Movie, for starters, he saves the entire
world from being swallowed by the legions of Hell by electrocuting an
undead Saddam Hussein with a combination of an overcharged
anti-swearing implant and his own colorful vocabulary.
Make the sociopath be charismatic and entertaining, so that the reader can laugh with them.
This works best with self-aware characters, who know exactly what they're doing, and they're enjoying it, and their anarchic and destructive energy is contagious. Some good examples can be found in the page Heroic Comedic Sociopath.
The Mask in the comics:
His comics incarnation, meanwhile, is a pure-up Villain Protagonist.
It also helps that so many of the characters who get picked on by The
Mask are Asshole Victims. In fact, in the movie it often seems as if
Edge City is swarming with all kinds of pests, weirdos, bullies, and
all-around Jerkasses whose only purpose in life is to drive Stanley to
impossible levels of madness and inspire him to wreak creatively
ghoulish destruction as The Mask.
Kai in Kung Fu Panda 3:
Kai from Kung Fu Panda 3 has one hell of an ego on him, constantly
boasting about his accomplishments (and getting annoyed when they
aren't recognized), along with having way too much fun in the villain
role for his own good. The fact that he does all of this while still
being very competent has made him quite endearing to the fandom.
Handsome Jack in the Borderlands games:
Handsome Jack is regarded as one of the most memorable video game
antagonists in recent years since the commercial and critical success
of Borderlands 2; players love to hate him for his disturbing yet
hilariously twisted morals, his bombastic personality, his bizarre
sense of humor, his strangely emotional nuances (that don't de-fang
his cruelty or megalomania in any way) [...]
See the spoon story for a short example, but really, he has many great lines.