WASHINGTON — The Pentagon is building a second courtroom for war crimes trials at Guantánamo Bay that will exclude the public from the chamber, the latest move toward secrecy in the nearly 20-year-old detention operation.The new courtroom will permit two military judges to hold proceedings simultaneously starting in 2023.On those occasions, Khalid Shaikh Mohammed and the four other men who are accused of plotting the attacks of Sept. 11, 2001, would have hearings in the existing chamber, which has a gallery for the public.Smaller cases would be held in the new $4 million chamber. Members of the public seeking to watch those proceedings at Guantánamo would be shown a delayed video broadcast in a separate building.It is the latest retreat from transparency in the already secretive national security cases at the base, where the military and intelligence agencies have been restricting what the public can see. That includes forbidding photography of sites that were once routinely shown to visitors and declaring both populated and emptied wartime prison facilities off limits to reporters.In Guantánamo’s current war court chamber, which opened in 2008, members of the public watching the proceedings live hear the audio on a 40-second delay, time enough for the judge or a security officer to mute the sound if they suspect something classified has been said.That allowed spectators in the gallery in January 2013 to see the puzzled look of an Army judge after the C.I.A. remotely cut off video feeds of the proceedings. Another time, only observers in the room saw guards bring an uncooperative defendant into court strapped to a restraint chair, with a soldier following behind carrying his prosthetic leg.In 2018, guards set up a hospital bed inside the courtroom for a disabled defendant that could not be seen on video feeds.But the new courtroom, in what is described as a cost-saving measure, has no such gallery. Only people with a secret clearance, such as members of the intelligence community and specially cleared guards and lawyers, will be allowed inside the new chamber.As a workaround, the court staff is designing a “virtual gallery with multiple camera angles simultaneously displayed,” said Ron Flesvig, a spokesman for the Office of Military Commissions. The public would be escorted there to watch the proceedings, streamed on a 40-second delay.During recesses in the current courtroom, lawyers and other court participants often engage with reporters and relatives of victims of terror attacks, routine contact that would be lost with the “virtual gallery.” So would the ability for a sketch artist to observe the proceedings live.The construction plan illustrates continuing improvisation at Camp Justice, the court compound at Guantánamo, where the military has been using modular structures and tents since 2007 to avoid building more permanent structures, which require congressional approval.The second court was designed before President Biden took office with an administration-wide goal of ending detention operations at the base at Guantánamo Bay. It is being built in the United States for assembly at Guantánamo and is expected to be up and running in the middle of 2023, Mr. Flesvig said.Meantime, workers can be seen at the court compound preparing a space adjacent to the existing courtroom for the new one. But Defense Department officials have yet to decide where to put the virtual gallery, or calculate its cost, he said.The new court has room for just three defendants, too small for the Sept. 11 case, unless the judge severs some of the five defendants from the joint capital punishment trial.The plan does, however, allow for a scenario of two death-penalty cases being tried at the same time. In the Sept. 11 case, reporters and victims would watch live. But family members and shipmates of the 17 sailors killed in the Qaeda suicide attack of the destroyer Cole off Yemen in 2000, who routinely attend sessions, would be kept away from the court with other observers, watching video feeds.It appears to be tailor made for the conspiracy murder trial of three men who were recently charged in two terrorist bombings in Indonesia in 2002 and 2003 that killed more than 200 people. Lawyer James R. Hodes, who represents the lead defendant, Encep Nurjaman, who is known as Hambali, said that even at the current court, access has been far from open.Public viewing at Mr. Hambali’s arraignment in August was strictly controlled by the military, which decides which reporters, law students or human rights advocates can board a Pentagon charter plane to travel to the base. The military also controls access to two remote video sites inside the Pentagon or at Fort Meade in Maryland.“I’ve observed trials in Mongolia that were more transparent than this,” Mr. Hodes said.To be sure, some secrets have been declassified, particularly in the death-penalty cases, which have been mired in pretrial hearings for about a decade.A medical expert recently testified in open court about the post-traumatic stress of a prisoner who was waterboarded by the C.I.A. in 2002. Previously, the doctor’s descriptions of the trauma would have been consigned to a classified session that excluded both the public and the prisoner.Separately, the intelligence services permitted open court discussion of something that defense lawyers had known for years: Under a secret agreement, the C.I.A. requisitioned nine F.B.I. agents and temporarily made them agency operatives to interrogate prisoners in a network of black sites where the C.I.A. used torture in its interrogations. The agreement is still classified, but the intelligence agencies last month permitted its existence to be known.But the new courtroom reflects a trend toward what appears at times to be a peculiar pick-and-choose transparency.For example, for 17 years the military routinely took visiting journalists to the detention facilities where most captives are kept, but required them to delete photographs that showed cameras, gates and other security procedures. Then, the military undertook a consolidation that moved Mr. Mohammed and other detainees who were held by the C.I.A. from a secret site to the maximum-security portion of those once showcase facilities — and declared the entire detention zone off limits to journalists.Their empty, formerly C.I.A.-controlled prison is off limits to reporters too. Defense lawyers who are seeking a preservation order on the site describe it as a rapidly deteriorating facility that was clearly unfit for the prisoners and their guards. One military lawyer who visited there recently described carcasses of dead tarantulas in the empty cellblocks.In 2019, a Marine judge, prosecutors and defense lawyers discussing a new triple-wide, wheelchair accessible holding cell at the court used the expression “jumbo cell” — derived from a Miami Herald article — 30 times in a single court hearing.Security officers subsequently sent word that the nickname for the cell, essentially a description of a security measure, could no longer be spoken in open court. The prohibition continues, although the military showed reporters the new jumbo cell before a hearing on the 20th anniversary of the Sept. 11 attacks.“This is an ad hoc classification system,” said James P. Anderson, the security specialist assigned to the defense team of Abd al-Hadi al-Iraqi, who has spent nights in the cell at the court complex. “Things that used to be unclassified become classified just because the person reviewing it is uncomfortable with its use. It defies all reasonable logic.”On the evening of Oct. 28, an anonymous government official sent word to the judge that a paragraph should be censored from a statement a prisoner was about to read to a military jury about his torture by the C.I.A.The judge considered the request and refused, noting that the statement was not classified.In it, the prisoner Majid Khan quoted Jose Rodriguez, the former C.I.A. counterterrorism director, as saying in a newspaper article that “mistakes were made” in the operation of a particularly grisly C.I.A. prison known as the Salt Pit. Mr. Khan was tortured there in 2003.In November, U.S. Marines escorted reporters and others to the fabled Northeast Gate, a passageway to Cuban-controlled territory.For this visit, the sightseers were told they could take selfies at the often photographed gate but were forbidden to post or publish them.To reach the gate, motorists drive past the remains of Camp X-ray, Guantánamo’s first wartime detention site, now a weed and rodent infested labyrinth of cells made of chain link fencing. Military officials for a time forbade reporters from filming there, invoking unspecified security reasons. A senior official intervened. Now, reporters who find themselves at the base on Jan. 11 can take pictures there — 20 years to the day of the arrival of Camp X-ray’s first prisoners.