Prince Harry is challenging the government’s decision to refuse police security during his visits from the US.
The duke has said he currently “does not feel safe” when visiting and has offered to pay for police protection.
Government lawyers said his offer was “irrelevant” to how officials took decisions over Royal Family security.
Following preliminary hearings in the case last month, Mr Justice Swift ruled on Thursday that parts of court documents in the case should be kept confidential.
Both the duke and the Home Office had made the application for some parts of the court documents to be kept private.
Thursday’s ruling only covers the redaction of documents and does not decide the duke’s claim against the Home Office or whether it can go ahead.
Prince Harry argues that his private protection team in the US does not have adequate jurisdiction abroad or access to UK intelligence information which is needed to keep his family safe.
Robert Palmer QC, for the Home Office, previously told the court the duke’s offer of private funding was “irrelevant” and that “personal protective security by the police is not available on a privately-financed basis”.
Speaking on Thursday, Mr Justice Swift said some of the information relied on in the case involved the security arrangements for Prince Harry and other public figures in the UK.
“For obvious reasons information on such matters usually remains confidential,” he said.
After the judgment was made public, Mr Justice Swift criticised Prince Harry’s legal team for breaking the embargo on the document.
Mr Justice Swift said a copy of Thursday’s ruling had been emailed to someone who was not a lawyer, against court rules, calling this “entirely unacceptable”.
Prince Harry is challenging the February 2020 decision of the Executive Committee for the Protection of Royalty and Public Figures over his security, after being told he would no longer be given the “same degree” of personal protective security when visiting.
The duke’s barrister, Shaheed Fatima QC, previously told the court that Prince Harry considers the UK “is and always will be his home”.
The duke and his wife Meghan live in the US with their children Archie and Lilibet after quitting as senior working royals in early 2020.
Prince Harry briefly returned from Los Angeles last year for the 1 July unveiling of the Diana, Princess of Wales memorial statue, and the day before he met seriously ill children and young people at a garden party and afternoon tea in Kew Gardens, west London.