I had a related problem a few weeks ago.
My solar inverter, which expects to talk to its own supplied proprietary Smart Meter with RS-485 Modbus, is in a different building from where my power comes in from the street, and it was not feasible for me to run a cable, especially since I already have ethernet between the buildings, and WiFi, and my own smart meter in the right place.
So, I actually reverse engineered the modbus link between the inverter and its smart meter (took a good few days!) and wrote my own software for ESP8266 to pull the data from my own smart meter through MQTT and then present this data in the correct modbus format when the solar inverter asks for it.
This did take a solid week, but I’m very happy that it works perfectly – it was the most elegant solution too, I now have three inverters each with an ESP8266 running my software pretending to be the proprietary smart meters, and they are all perfectly happy.
So, as for your problem: It’s certainly possible to receive a packet, forward it, and then send it out at the other end… but as you do, you will be introducing significant delay, and it’s very possible that the requesting (modbus master) unit will not be happy with this.
If, on the other hand, you were to reverse engineer the protocol, then you could cache the correct data in advance in the modbus slave that you make yourself, and then it will be already be there when the master (your inverter) asks for it, so it will be none the wiser.
This is not an easy problem, but it is possible.
I had never done this kind kind of reverse engineering before.
In my case, once I figured out that my inverter was always asking making the SAME request, always requesting the SAME 23 values, then it was just a matter of figuring out what the values were.
To do that, I used an ESP8266 to make the same request that the inverter made, and then I used incandescent lights (power factor 1.0), LED lights (power factor 0.5) as artificial loads, and a whole lot of trial and error, until I knew exactly what each value was… 3-phase volts, 3-phase amps + total, 3-phase watts + total, VA, VAr, power factor, frequency, and other things I can’t remember now.
Anyway, if you’re feeling adventurous, go for it!