Loudmouth “pharma bro” Martin Shkreli talked himself into a much harsher prison than he was ever likely to face for scamming hedge-fund investors, leading defense lawyers told The Post on Thursday.

Brooklyn Judge Kiyo Matsumoto on Wednesday ruled Shkreli was a “danger to society” and revoked his $5 million bond over a Facebook post that offered $5,000 for a lock of Hillary Clinton’s hair.

With no prior criminal record, the former drug company CEO’s securities-fraud convictions would likely have landed him in a minimum-security prison camp, sources said.

Instead, at least until his January sentencing, he’s cooling his heels in Brooklyn’s Metropolitan Detention Center, a place that looks good only when compared to the “supermax” prison in Florence, Colo., or the Marion, Ill., slammer where mob boss John Gotti served time before he died, a defense lawyer said.

“He’s in the worst prison that he’ll ever be in, considering the charges he was convicted of,” the source said. “He really put himself in a bind.”

“He’s going to be in total shock,” said attorney-in-charge Deirdre von Dornum of the Federal Defenders of New York’s Eastern District office, who visited a client at the MDC on Wednesday.

“It’s freezing cold right now. The inmates are wearing hats and are wrapped in towels to keep themselves warm, because [officials] keep the air conditioning up for some reason.”

“In the winter, it often gets very hot,” she added.

A woman who was waiting to visit her brother in the MDC on Thursday evening said Shkreli, 34, “didn’t know what he [was] getting into.”

“There’s a lot going on behind these walls, I would hope he don’t think it’s a resort,” she said.

“There a lot of gangs in here. And after the gang thing, then there’s the color thing. … It’s not something small when you in here.”

In 2008, Ponzi schemer Raffaello Follieri — an ex-boyfriend of Oscar-winning actress Anne Hathaway — complained that he got sick in the MDC after being served spoiled food and forced to use “unspeakably unsanitary” bathrooms with “excrement in the showers” and rats “roaming freely in the area.”

Five years later, a Brooklyn federal judge blasted the Bureau of Prisons for letting gang member and cop-killer Ronell Wilson intimidate fellow inmates and manipulate staffers — including a correction officer, Nancy Gonzalez, whom he knocked up during a “months-long sexual relationship.”

The BOP currently is fighting a class-action suit filed in Brooklyn federal court by inmates who claim they were subjected to “conscience-shocking, oppressive, egregious, capricious and dangerous conditions” at the MDC.

One affidavit was submitted by crooked Bronx pol Pedro Espada, who claimed laundry dryers “vent directly into the sleeping, eating, and living space,” forcing inmates to breathe in “a mass quantity of particulate matter.”

“Mold is omnipresent on ducts, shower areas, ceilings, and walls,” wrote Espada, who’s since been moved to a halfway house.

“Instead of correcting these health hazards the BOP and MDC make the conscious decision to paint over the mold. The painting … is usually done prior to inspections and 3rd party visits (such as Regional Office or Judicial visits).”

A federal grand jury also is investigating corruption allegations, some tied to pending criminal charges against three MDC supervisors accused of raping and sexually abusing female inmates, according to a source familiar with the matter.

The BOP declined to discuss Shkreli’s incarceration, citing security and privacy concerns.

But people familiar with the MDC said he was being housed in the “Receiving and Departure Unit,” where he was strip-searched on arrival, clad in khaki prison garb, tested for tuberculosis and questioned about his health and mental state.

Following the intake process, Shkreli could be moved into general population, or placed in isolation for his own protection.

“There might be someone who would just want to hurt him” because of his cockiness and notoriety, said a defense lawyer who was visiting a client Thursday.

The woman who was visiting her brother said Shkreli’s fate was largely in his own hands.

“It all depends on how you present yourself here. If you gonna be arrogant, you’re going to be treated a certain way,” she warned.

Additional reporting by Gabrielle Fonrouge