Martin Shkreli cannot have back his $5 million bail, even though he's in jail.

Judge Kiyo Matsumoto denied a request to return the funds to Shkreli, who was convicted of fraud in August.

"The court concludes that Mr. Shkreli will not suffer an 'undue hardship' by the retention of his bond," Matsumoto said in a court order filed on Thursday.

Shkreli's lawyer Ben Brafman wrote a letter requesting the bail be released. He said the money would not go directly to Shkreli, but to a fund managed by Fox Rothschild LLP to pay off Shkreli's growing tax debt. Brafman declined comment to CNNMoney.

The judge said the court needs to hold onto the money while it decides whether to impose fines or restitution as a result of Shkreli's investment scam. A hearing is scheduled for October 24.

Shkreli is incarcerated in a federal jail in Brooklyn while he awaits sentencing on January 16, 2018.

He's been there since September 13, when Matsumoto revoked his bail. The judge ordered him to custody after Shkreli had offered, via social media, $5,000 to anyone who would grab a strand of Hillary Clinton's hair.

Shkreli, 34, boasted of his wealth and used an E-Trade account, which was worth $45 million at the time, to post his bail.

Earlier this year, Brafman unsuccessfully requested a reduction in bail to $2 million, noting that Shkreil was worth "tens of millions" but couldn't access the money because it's illiquid.

Related: Martin Shkreli is now inmate #87850-053

Shkreli, a hedge fund manager and former pharmaceutical executive, posted bail on December 19, 2015, the day after he was arrested and charged with eight criminal counts for running his investment portfolios "like a Ponzi scheme," as the prosecutors put it.

He lied to investors about the disastrous state of his funds while using their money to pay off unrelated debts and penalties.

The fact that he eventually made money for his investors anyway was a key part of his defense but failed to sway the jury.

He was convicted, on August 4, 2017, for two counts of fraud and one count of conspiracy to commit fraud. He could be sentenced to up to 20 years in prison.

Shkreli is widely reviled for hiking up the price of a life-saving drug, Daraprim, to $750 a pill from $13.50 while he was CEO of Turing Pharmaceutics. The price-hike was not related to his fraud conviction.

Shkreli seemed to revel in his notoriety. He was kicked off Twitter and Periscope for harassing behavior.

Related: Martin Shkreli just wouldn't stop talking during trial

Defense lawyers tried to insulate the jury from Shkreli's caustic behavior, but he continued his antics in the court, at one time visiting a room used by reporters without his lawyer present to insult and belittle the prosecutors in his case. He also continued to discuss the case on YouTube.