It is no problem using a VFD to power a 240V motor in a 400V system with a 400V VFD. You set up the VFD with the motor name plate parameters. The VFD ,simply explained, put out a voltage in linear relationship to the Hz. That is a 240V 50Hz motor shall have 120V at 25Hz, 216V at 45Hz as two examples. This setup also allowes for "oversyncronous" operation, that is operation above 50Hz without loss of torque. At 70Hz the VFD puts out a voltage of 336V. This can be done because the supply voltage is 400V and the motor is only 240V.
However a 400V VFD can not be connected to a 240V supply voltage. The reason for this is that the low supply voltage alarm would immediately be activated and the VFD most likely wouldn't even try to run the motor.