Yes you can apply 24V directly to those inputs; but be very careful to use the correct pins. However, if there is a difference in ground potential between the servo driver and the Duet (which is likely, if the same PSU supplies the motors as supplies the 24V circuitry in the driver), you should use an opto isolator in order to avoid false readings.
