It would come down to how crooked the judge and cops are.
Even if the law is in black and white in your favor, the cop can lie and say he paced you going 28 mph, so therefore it's not a bike anymore it's a moped.
Better to just avoid the situation altogether. Mount your battery in a clever way that doesn't advertise you have an electric helper. Don't dress like a "criminal on a bike."
Stay low profile, obey the traffic laws, don't look like someone a cop wants to pick on.
I ride in an area that is legally not e-bike friendly. I pass closely by police and they never give a second glance; all they perceive is a guy riding a bicycle somewhere with a backpack and a bunch of pannier bags. I have lots of bright lights and play the part of an adult commuter.
Save court justice for TV fiction.