If you want to take it to extremes using the Dupont connectors being plugged in wrongly then you can
Make the multi pin plug asymmetrical by not using one or more of its positions and block those positions on the header socket too.
Block all of the remaining unused header sockets on the Uno to prevent them being used.
Now the plug can only be placed in one position and one way round
Whether it is reasonable or sensible to go to these extremes only you can decide
Come to that it may not be sensible to use Dupont connectors and pin headers in the first place. What sort of application is it for will the connectors be used and an in what environment ?
In this type of situation dont bother with hobbyist solutions like dupont connectors. way to easy for accidental disconnects, plugged in wrong etc. etc.
I much prefer to use Arduino’s that do not have connectors already soldered in place. That way I can solder in pigtailed locking connectors directly to the board that can only be plugged in to the mating connectors correctly. Then I encase the whole thing in “electronics potting compound“ thus creating a black box that no one can mess with.
For this solution, what'd you do with the Arduino's female header, or what kind of Arduino do you use for said board that is plugged with the mating connectors?
would take a difficult time in case the Arduino is damaged and that it has to be replaced with a new one, and it likely would have the people there other than me not knowing how to integrate the replacement Arduino on said machine
Connect the connector to a separate "shield" or "carrier" board, which contains headers into which the Arduino board plugs. This way the Arduino board can be easily replaced without the need to do any soldering.
Of course that only moves the problem to the "shield" or "carrier" board. However, a simple board that only provides electrical connections, without any electronic components, is less likely to require replacement than the Arduino board (due to the presence of electronic components which are more easily damaged if subjected to conditions outside of the rated tolerances).
Guess unlike the Arduino itself (which may be replaced), shield boards can be modified and stay like replacing the female headers in said shield board with a keyed socket, right?
Yes, that is the idea. A "shield that only contains headers, PCB traces, and a connector can withstand any sort of exceptional electrical conditions (ESD, overvoltage, reversed polarity) that are likely to occur.
If you are using the UNO R3 as indicated by the Classic > UNO R3 forum category you chose for this topic, then the headers are keyed out of the box.
One of the headers on the boards with the UNO form factor is offset from the 0.1" grid. Although this offset was a somewhat unfortunate mistake, it does make it so that you physically cannot connect a "shield" to the board incorrectly.
I guess I'd be using shield board with sockets to make the Arduino easily replacable, but still allows a room for unified sockets that can't be connected wrong.