So I want to buy a bike with a rear hub keyde motor, which is only available with the 2x9-speed Sora groupset (probably 3500) in Australia. If I buy it, I might want to upgrade it to the 105 2X11 5800 groupset. I went into a bike shop and they said something about the 11 speed cassette rear hub being incompatible with a 9 speed cassette rear hub. So how would the switch work if the rear hub contains the motor? Here and here are pictures of the hub. Can somebody please help?
The short answer is that the 11 speed cassette is slightly wider than a 10 speed one (34.95->36.75mm = +1.8mm) which in turn is slightly wider than a 9 speed one. Sheldon Brown died before Shimano 11 speed came out, so his chart only goes up to Campag 11 speed, that that suggests 36.5mm for Shimano 9 speed compared to 40.1mm for Campag 11 speed (+3.6mm). You'll note that those numbers don't match up, so it comes back to "measure it yourself".
To prevent the practical problem of someone buying the wrong cassette, fitting it, then complaining that it doesn't work, they have a different arrangement of ridges on the freewheel. In your case, you already know that you need a new derailleur and shifter, but not everyone does.
Now, it's possible you could change the freewheel to an 11spd one and spread your frame slightly to accommodate it, but that would be a DIY task not a bike shop one I suspect. The bike shop could well refuse to spread an aluminium frame because that would probably fatally weaken it, but under Australian law they're liable for any damage they do (including the key point in this case, making the bike not fit for purpose). With most steel frames you could reasonably spread them 4 or 5 millimetres, use a longer axle and an extra spacer, and the only question would be whether you can fit the 11 speed freewhel you that hub.