If you want to fasten the encoder to the motor shaft, ie not the gearbox output shaft, then thats going to be very tricky as the motor is a sealed assembly, even a model engineer with lathe & equipment would find that tricky.
You could however connect the encoder to the output shaft of the gearbox by adapting or making 2 pulleys and using an O ring or other drive belt between them.
If absolute accuracy isnt required you could use armature feedback to detect back emf pulses from the motor, but thats not that accurate.