That depends on what type of pin your rack uses. I am using a Rocky Mounts rack with a threaded anti-rattle pin, so I have to use their pin. There is no way to get the pin in from the left nor to get the key out of the lock with the pin coming in from the right.
Their bolt looks like this:
Hitch Bolt- MonoRail/BackStage/SplitRail/WestSlope
I bought this Curt pin and lock -
https://www.amazon.com/gp/product/B06VTJMBZZ - and while the end of the Curt pin is slightly larger than the end of the Rocky Mounts pin, it is close enough that the lock works, and since it is a right angle lock there is no interference between the brake light connector and the key.
So depending on the pin size and type there may be something out there that will work. If you have a non-threaded pin there are probably a lot more options. I was lucky the one I found was a close enough match to work.