That's probably why "Court Martial" had that early scene establishing that multiple other starships were in port for maintenance or repairs -- they were the source of the officers who constituted the jury panel.
Kirk specifically said that the officers who would comprise the court were "proceeding to Starbase 11."
If this was 1798 Jamaica, Commodore Stone (who becomes Admiral Stone because a Commodore wasn't a rank in the RN (before 1997), it was a posting), as the senior Flag Officer present, and thus the senior representative of the King, would be required to preside over the trial.
Not exactly. In that situation the senior officer present, if so empowered by law (a commander-in-chief or another commander specifically delegated convening power by a commander-in-chief), was the convening authority who could order a court to sit. The convening officer could not serve on the court.
However, there was also provision that if five naval vessels were assembled in foreign waters, the senior officer could convene a court-martial and could preside. The vessels would have to be able to stay on the same station until the trial was concluded, though, so I suspect this was much less common than having a flag officer convene a court.
There was also much less reliance on technical details and professional knowledge, as everyone involved was a part-time lawyer at best.
Yes, in the system at the time there was a judge-advocate as a sort of referee of the trial. This was usually a flag officer's secretary, then more of a civilian than a naval officer. They were supposed to be familiar with the law, but they were not lawyers. There was no provision yet for prosecutor or defending counsel, the court questioned witnesses directly.
The process in "Court Martial" is more like it would be around WW2 under the US naval justice code ("Rocks and Shoals"). After the war and the unification of the armed forces departments, the Uniform Code of Military Justice was enacted, and courts became more like those of the civilian word, with a separate judge and jury instead of the president of the court also being a deliberating member. A much different system, and one of the reasons the 2023 version of
The Caine Mutiny Court Martial missed the mark by setting the story in the present day.
If we assume that Star Fleet is making similar concessions to reality, Stone's dual role doesn't become much of a problem. (One could also argue that, perhaps only on paper, Stone isn't actually bringing the charges, Shaw is, and Stone is just the one telling Kirk about it.)
It's still a huge problem. Stone conducted the investigation, determined that the charges should be brought, and presided over the court. That's like one person being the police investigator, the district attorney and the trial judge. The potential for abuse is enormous.