You can send arbitrary I2C commands on Duet 2 using M260. I advise against using I2C to connect anything that isn't located very close to the Duet and powered from it. I2C was designed to be used to interconnect chips within a single PCB, so it is not noise-tolerant, and the I2C protocol does not include error detection or recovery.
I2C is not currently supported by Duet 3. Although Duet 3 has some I2C-capable pins, you would need to make a hardware modification (change a resistor) to make them usable for I2C.
Duet 3 supports UART Tx/Rx on some of the IO connectors. I will provide facilities to access these UARTs via GCode in due course. I expect to make the same facility available on the PanelDue port of Duet 2 in RRF 3.