For the software side, if you’re using Arduino to program the ESP then there are a few Modbus “Slave” libraries around for that. Just search around. Personally I use Mudbus. I don’t know anything about Domoticz but I’m assuming it has a Modbus “Master” plug-in?
For hardware, if you need to use RS485 then you’ll need a ttl to RA485 adapter with 5v to 3.3v level converter like this for the Arduino a RS232 to RS485 converter like this for your PC.