Once upon a time in Los Angeles, there was a very real gangster named Mickey Cohen. Any resemblance between Sean Penn in “Gangster Squad” and that guy – a publicity-hungry man about town who squired strippers around and took it hard when his pal Bugsy Siegel went to that great Vegas in the sky – is purely accidental.

But then despite distant origins in a seven-part Los Angeles Times series written by reporter Paul Lieberman, you’d have to say that about the whole movie, a silly, bullet-riddled knockoff-noir that somehow turns Cohen into LA’s “Public Enemy No. 1” even though there are those lawmen who rated him “no higher than the leading public nuisance.” (See Bruce Henstell’s entry in ex-Buffalonian Lawrence Bock’s anthology “Gangsters, Swindlers, Killers & Thieves: The Lives and Crimes of Fifty American Villains.”)

The two times, for instance, Cohen did serious jail time, it was only for tax evasion.

Lieberman turned his L.A. Times series into a book that was then turned into a film script by writer Will Beall of TV’s “Castle” (not exactly a bedrock of realism, eh?) and is now an entertainingly foolish shoot-em-up called “Gangster Squad.”

They love this tale out in LA’s movie boardrooms – the secret squad of cowboy cops inside LA’s police force in the late 1940s and ’50s, charged with bouncing organized crime out of town. The James Ellroy novel of it, “L.A. Confidential,” was turned into a great 1997 movie. The year before, the not-as-great “Mullholland Falls” told us about the same guys in a movie starring Nick Nolte.

Nolte’s in this one, too, 16 years later, looking and sounding a bit like a beached walrus. He plays Police Chief William F. Parker, who gave his name to LA’s police center and was, in life, a merry paranoid known to blame communists for the existence of organized crime.

You no doubt remember TV’s version of “The Hat Squad” based, again, on the real guerrilla squad inside the LA cops.

The real Hat Squad – whose very idea now could terrify any genuinely law-abiding citizen – was known for its immense beef and brawn underneath their fedoras.

In the movie, the “Gangster Squad” is comprised of, among other actors, Josh Brolin, Ryan Gosling and Giovanni Ribisi, the latter two looking as if a good stiff Santa Ana breeze could knock them on their patoots. (Nor is Brolin – recently busted on New Year’s Eve in LA for “public intoxication” – all that beefy either.)

Cohen is played by Penn, looking a bit like a miniature Frankenstein monster and having a grandly hammy time in the role (accounting, in truth, for a good half of my enjoyment).

Given the amount of gunplay in this movie, I suppose one could easily deplore its pseudo-noir silliness. Cohen’s idea of wit, for instance, is to tell a betraying thug, “it’s like they say, all good things shall be burned to the ground for the insurance money.” Next thing you know, that very thing happens to a building in which the betrayer is trapped in a burning elevator.

When Cohen tells his meanest lieutenants “you know the drill” about dealing with an underling who’s just lost a giant drug shipment, what you see in the next scene is the two guys dispatching the incompetent with a very real drill. At that point, you’ll remember that director Ruben Fleischer directed “Zombieland.”

Writer Beall’s “Castle”-esque version of noir turns the word “sophisticated” into the past tense of a transitive verb synonymous with sexual intercourse. You’ve got to guess that the real “Gangster Squad” played very different games.

Brolin plays O’Mara, the head of the squad who assembles them all with the advice of his brainy, pregnant wife (played by Mireille Enos of “The Killing”). Gosling plays his pretty boy No. 2 who has a “smart mouth, but he’s dumb where it counts” (an eloquent description, in fact, of the whole movie).

A deeply foolish piece of work, in every way, let’s admit, which is why all the gunplay can’t be taken seriously in the slightest.

The hats, though, all look great – even Penn’s Leo Gorcey/Tom Waits fedora with the front brim flipped up.