I've noticed that when mounted in the pilot seat when you ALT look 90° to the left/right/up/down the Unlock icon disapears. In other words, if the Code Lock is within the player camera's view frustrum then you see thet Unlock icon. So if you also allow for rotation of the Code Lock (i.e., X, Y, Z) it should fix this issue.
There are certainly alternate positions and/or rotations for each vehicle that resolves this issue. For example, I have a mod that adds a coffin to the bottom of the Attack Heli and when a code lock is palced on it I DON'T see the Unlock icon as it is outside of the player camera's view frustrum. Same for the mini, put a crate on the back with a Code Lock on the back and you DON'T see the Unlock icon when mounted.
But then again, it might have something to do with the camera itself. That is, perhaps it's not the player's camera that is active when you are in a vehicle, or perhaps the player's camera is moved/altered once you mount a vehicle. Or some collider is added to the vehicle and no matter where the COdde Lock visibly is, you will always be inside of the collider that triggers the display of the Unlock icon. :(