The woman, who has an underlying health condition, gave birth to a baby a month ago and is in an induced coma.
Mr Justice Hayden ruled that doctors can lawfully stop providing life-support treatment to the woman.
A specialist told him that everything had been tried and the woman’s chances of recovery were “zero”.
The judge considered the case at an urgent virtual hearing in the Court of Protection, where issues relating to people who lack the mental capacity to make decisions for themselves are analysed, late on Tuesday.
He said the woman, a Muslim who was married and also had a three-year-old daughter, could not be named.
Bosses at the University Hospitals of Leicester NHS Trust had asked him to rule that ending life-support treatment would be in the woman’s best interests.
The woman’s husband and sister said she should be given more time and treatment should continue.
They said Muslims believed that only God could end life.
But the judge said evidence showed that doctors were no longer preserving the woman’s life, but prolonging her death.
He concluded that ending treatment would be in her best interests and said she should be allowed to die with dignity.
Mr Justice Hayden said the woman’s “life and hopes” had been extinguished by “this insidious virus”, and a young family “split apart prematurely”.
“This family is seeking a miracle,” he said. “This is a very young mother in circumstances of almost-unspeakable sadness.”
He added: “It is a tragedy of an almost-unimaginable dimension.”
Mr Justice Hayden said doctors had prepared a palliative care plan and the woman’s family would be able to see her.
“The objective is not to shorten her life,” he added. “(But) to avoid the prolongation of her death.”
The judge was told that the woman suffered from Addison’s disease – a rare disorder of glands that produce essential hormones.
He heard that she had developed Covid-19 while at home and been rushed to hospital a month ago when 32 weeks’ pregnant.
Doctors had delivered her son by caesarean section shortly after she was admitted.
They said her pancreas had ceased to function and one lung had “died”.