Vehicle turret will avoid shooting you, but only if it can see you and you’re within 24 tiles from it.
It will not shoot any target within 15 degree angle from you. If you stand within 2 tiles from the turret, the angle becomes 30 degrees, if adjacent to it - 60 degrees.
It will prefer closest targets that don’t stand within that 30 degree (15 clockwise, 15 counter-clockwise) cone.
Note that it ignores distance - if you’re 20 tiles from the turret and zombie is only 5 tiles from it, it is still “protected” because it’s in the cone.
Friendlies are ignored. Neither targeted nor protected.
If you become invisible to the turret for any reason (most likely darkness), it will stop caring about not hurting you.
I didn’t see any code that would prevent it from wrecking the car itself, but I couldn’t “force” it to damage itself during any of the several short tests. It seems that even when it hits the vehicle it is a part of, it won’t do anything.
I managed to get it to try shooting through me, though. That 60 angle when adjacent apparently isn’t enough.
Don’t mount tiles within 2 tiles from your seat and don’t use area of effect turrets and you should be fine.