The D.C. Court of Appeals reversed yesterday a gun conviction against Michael N. (Miami Mike) Kleinbart because, the court found, the judge in the case violated Kleinbart's constitutional right to a public trail.

During a portion of Kleinbart's five day trial in D.C. Superior Court in 1976, the door to the courtroom was locked, excluding the public from the hearing, the three judge appellate panel said.

Judge Norma Holloway Johnson, who presided at the trail, ordered the door locked without notice to lawyers in the case and refused to explain her reasons for that decision, the appeals court said.

The appeals court, in an 11-page decision, held that "only under the most exceptional of circumstances" can a criminal trail be closed - even partially - to the public. To do so, the trail judge state reasons for such action, inform the lawyers and allow them time to respond before the action is taken, the courtsaid.

Kleinbart, 37, is serving a maximum of 32 years in prison in connection with the wounding of two U.S. Park Police officers in May 1975. He was also sentenced in March 1977 to 20 years to life in prison for the shooting death of Clayton Tyrone Bennett, whom Kleinbart contended he killed in self defense.

The incident with the Park Police officers occurred four days after Bennett was killed. The gun conviction that the appeals court overturned yesterday arose from the Bennett shooting. The appeals court decision does not affect Kleinbart's convictions or prison sentences in connection with the other charges.

In an opinion for the court, Chief Judge Theodore R. Newman Jr. wrote that the right to a public trail was incorporated into the Constitution to ensure fair trails and to act as a restraint on the possible abuse of judicial power.

While the right to a public trail is not absolute, Newman said, the courts must "always remain sensitive" that only exceptional circumstances will justify closing off even a portion of a trail to the public.

The standard to be used must be "strict and inescapable necessity," Newman said, such as when the court recieves evidence of trade secrets or testimony from police officers engaged in undercoer work.

Judges John W. Kern III and George G. Gallangher also participated in the decision.