Ok, measure the voltage across the red and the black wire of the manual speed potentiometer on the motor controller.
Be careful not to touch any of the wires to the potentiometer as they are likely to be at or near mains potential (110V). If the voltage between the read and black is not greater than 12V, then you should be able to connect the G540 analog outputs in place of the potentiometer.
Please take note. There is likely to be mains potential voltage on these potentiometer wires. If you do not understand or are not confident in doing this yourself. Find a qualified electrician and get them to do it for you.
The motor controller has a safety feature so that it won't turn on unless the speed pot is turned down to zero. This shouldn't be an issue as the G540 will be putting out 0V initially, until a speed is commanded by Mach3.
Also, what you could do is leave the potentiometer in place, but also connect the red and black wire to the G540. Then use a SPDT throw switch that connects the white wire to either the potentiometer wiper OR the G540 VFD control voltage output. That way you will have auto/manual control, just by flicking the switch.