Those sorts of codes do exist already. The problem is that bike manufacturers will put on a "go fast" switch with a "Don't flip this or you'll be breaking the law" note in the manual.
Of course, a lot of people flip that switch because 20mph can feel pretty slow.
The Dutch seem to just do the sensible thing and have mobile e-bike dynos. If they suspect the bike is not properly regulated, they'll test it and keep it if it fails.