I can see a way to do it at compile-time if the constant identifiers (e.g. use 4 instead of orangeLED) are not used. But that would place an annoying restriction on the user.
I think the only way to do it at run-time would be to maintain a global integer set. That's not especially difficult but more code means more possibility of bugs.
The biggest caveat with run-time detection would be deciding how to report the mistake. Dealing with it during construction is certainly problematic.
Now that I think of it all I was really after was some way to let a human know there's a problem before the hardware starts breaking. So compile time would work too.
At a minimum I suppose one could flash the built-in LED on an UNO. But, what if the built-in LED is one of those designated for a flasher? Possibly a message could be sent to the serial monitor.
I think a comment to the effect of 'Don't do this!' may be the answer.