Crigg has given good tips
BUT
The rear-motor e-bike freewheels are often a special case as the axle has a wider cross section than a standard wheel. Most freewheel tools cannot engage the splines as the centre bore is less than the axle diameter.
To perform this operation at the shop, I had to buy a Park FR 1.3 which is drilled with a 15mm bore.
https://www.parktool.com/en-us/product/freewheel-remover-fr-1-3?category=Cassette+%26+Freewheel
I do not know if there is currently an alternative product, I could not find another.
You cannot modify a freewheel tool with a 15mm drill bit typically, because the tool steel is so hard.
Maybe this doesn't apply to you specifically but it will no doubt be useful for someone.