I do vaguely seem to remember this being asked before, maybe as a question about using a SIM800 cellular data connection when Wi-Fi isn’t available.
It should be fairly easy to do. Search the forum for code example about re-connection routines - this may be a good starting point:
Instead of re-connecting to Wi-Fi when it’s available again, switch over to trying to connect via Ethernet instead (and vice versa).
Pete.