Well I've never played any of the Ace Attorney games before and I have very little knowledge regarding them, so I can't tell you anything about Ace Attorney. However as a long term Pokémon fan, I can tell you that there was an episode where Ash appeared in a courtroom, or at least role played and pretended he was in a courtroom.
In BW077, titled "Evolution by Fire!" Ash, Iris, and Cilan are on their way to the Icirrus City Gym when they decide to spend the night at the Pokémon Battle Club in Astilbe Town. There they witness a Double Battle between two Trainers: Shamus, with his “Fire Warriors” Heatmor and Emboar, quickly defeats Kylan, with his Mienshao and Watchog. At dinner, Tepig seems to recognize Shamus and goes bounding up to him. Iris reminds Ash how he and Tepig met after it was abandoned by its Trainer in Accumula Town—and based on Tepig’s reactions, it appears Shamus was that Trainer! Ash and Iris are furious and demand an apology for how he treated Tepig, but Shamus insists he left Tepig behind for its own good because it was too weak to battle. Cilan gets in the middle and says that the only way to settle this is with a trial, and it just so happens that he's a judge connoisseur. The cafeteria suddenly turns into a spacious courtroom with Cilan as judge, Tepig as plaintiff with Ash as his counselor, Shamus as the defendant, and Iris, Pikachu, Snivy, and Axew as the audience.
Apart from this episode I don't think there has been any more episodes where Ash appears in a courtroom.
I wish I could of been of more help, but as I said before I've never played the Ace Attorney games and I have very little knowledge regarding them.
Source: Watched the majority of the Pokémon Anime.