I'llConsider a frame lock. Also known as ring lock or hub lock. These are the standard lock of Holland (The Netherlands). As the name suggests it is permanently attached to the frame, it secured like a ring through the spokes preventing ride aways, a chain (or cable) that snaps into the lock is optional.
Here is how it works in practice, normal bike rack, no change. Night at the square?: Park In front of a cart on the inner square and use the frame lock without the chain. Ebikes are too heavy to carry away and it can't roll.
They are heavy but on an ebike that doesn't matter. Available on Amazon but might be cheaper on
Bikeinn | Online store for bicycles and cycling equipment.
Axa Unisex - Adult Defender with RL 100 Bicycle Lock - Black, One Size
https://a.co/d/j3vPG6a