What I would do is throw (not literally) the whole motor onto the mill. Then I’d put a couple parallel bars in the vise, set the shaft (large part) on those, then clamp the vise on the shaft. The body of the motor would hang out the side of the vise. Then I’d center it up with an edgefinder going off the insde face of the vise jaws. Then I’d go in with an endmill and mill a keyway in the motor shaft (large part of the shaft). Then I’d bore the gear to fit over the shaft, and then I’d broach a keyway in the gear.
Of course, this would only work if the gear is big enough to be bored out to fit over the big part of the shaft, and the shaft has to be a standard size.
As for your question about filling in the voids, you may be able to use some sort of epoxy but I’m not sure if it would work.
What would probably be the best solution would be to set up the gear in a mill (preferable with dro). You can use an indexing head and a collet to hold it so you clamp on all the teeth so you won’t flatten any. You won’t need to clamp very tight. Then get the gear centered by the bore. Then get an endmill of diameter that is the distance from flat to flat of the shaft. Then mill in the gear, the shape of the shaft. Of course this only works if the distance from flat to flat on the shaft is a standard size.
May I ask, why are you using a plastic gear as opposed to a metal one?