Part of me actually believes Trump wanted this scathing ruling.
He knew from day one there was never a chance he was going to win this case on the merits, even on appeal. So as usual, his goal is to attack the process. He's been flinging shit at the DA, the judge, the clerk, and anyone even remotely involved with the case to see who bites at it, and the Judge may very well have taken the bait here.
The merits of the case no longer matter to Trump. So he wants the appeal to be all about the process, not the facts. He wants to show that Judge Engoron was "biased from the beginning". He's going to use Engoron's ruling on appeal to say that it's proof that the judge had it in for him from the beginning. He's going to say that Engoron dismissed their testimony by implying they were paid off to commit perjury on the stand with no evidence. He's going to say that subjective opinions cannot be lies. Whatever he can come up with. But the main point is that he's hoping to get his case in front of conservative judges or even up to SCOTUS in hopes that the judges will ignore the merits of the case and instead focus on perceived bias.
At the very least, he's going to use the ruling on the campaign trail to shore up support among his base and drive campaign funding because he knows his base will eat it up and throw their money at him. And as a bonus, he's probably hoping that someone actually follows through with a threat against Engoron and send a message to other judges and jurors, which has already proven to be an effective strategy for him.