Do you mean the PLC program can selectively enable/disable its own Modbus/TCP server? There isn't such an option on these PLCs at the moment.
To prevent access to the Modbus/TCP server you can enable the trusted IP address and put in an invalid IP address there, which will make the Modbus/TCP server become inaccessible.