At least in federal court, the vast majority of cases never get to trial, they are settled or dropped.
It is that way in most jirisdiction, covil and criminal - judges want people to drop silly cases, take the settlement, take the plea...
Judges hate to make decisions at trials that can be appealed and reversed. They prefer people “decide” on their own to do whatever.
It’s not that a judge can stop frivolous lawsuits (that would involve making a decision they have to own). It’s that they can encourage the officers of their court to communicate to their clients their chances of winning. And the judge will remember the idiot lawyer that came before them (or their judge buddies in the office next door) with nonsense. Next time that lawyer wants a favor from the judge whose time was wasted by nonsense, how do you think the judge will lean?
There is a literal formula they do and they
blather and come up with some percentage, and remind you you could lose. And wait in silence and stare at you.
If the judge wants the case to go away, defying him will only annoy the court.