Under what conditions do you hear the sound? If it is only under specific conditions (speed, load, temperature, etc) it could help narrow down the issue.
There are a number of groaning, grinding, and other noises that are very common to DD hubmotors especially with trapezoidal (square, non-sine) controllers, that often only happen at certain speeds or under certain amounts of load vs throttle input. If i's one of these noises, changing to a sinewave controller (especially an FOC type) may make it completely silent.
Sometimes the problem is interference between halls and phases when it's only under high loads (high motor phase current), and separating the hall and phase wires to different cables and different routing, or shielding the hall wires, can help or fix this (but sometimes it makes no difference).