Pirro's actions make a lot more sense if you consider that he most likely didn't know about the trial beforehand either.
There's a slim chance that he did, of course, but it's a lot more likely that he only figured it out when he was facing Scaracci and their contradicting stories. So after killing him, he finally has time to connect the dots.
It was all just a test. A rigged game from the start. They have no control over their lives to begin with, but that last ounce of autonomy was ripped from him now. A successful mission can't save you if you were never meant to succeed. What happened in the sewers was just supposed to lead up to this. They were never meant to make it out together. They aren't meant to make it out of this together. Their parents have total control over everything, so now that they decided to set this up, there's no way out for him. He has no choice but to play their game. The only thing he can do is try to win it.
That's the only way for him to take a little bit of freedom in his life.