I feel like there is of course an obvious proximity factor, but when I (as Pharrah in my example) try to sneak a peak from behind a corner and shoot the turret one rocket at a time, it seems to often target me even if there are other potential targets nearby.
So I was wondering if there is any other logic here other than "The turret targets the first enemy it sees and shoots it until it is dead, or leaves its line of sight" ?
Edit: After some games, I have a strong feeling that the turret has a preference for characters it can kill quickly (like Pharrah or Genji) and is less prone to shoot tanks. This is a subjective view but in the same game I played genji and zarya and found myself targeted by the turret a lot more often with genji.
Edit 2: I tried to be careful of its behavior during my last games and the turret definitely takes into account who is attacking it. I was farther away from the turret than my teammates and I started firing at it. After a few rockets (I just needed one more to destroy it), the turret changed its target to me although there were still other targets much closer.