if an enemy attacks tarn, tarn gets a target lock on them. Can he spend it during that enemy attack if he had the R17 astromech?
Tarn's ability
Yes he can.
But note that R7 works only once per round.
Can an opponent spend their target lock to reroll dice I just made them reroll?
Can an opponent spend their target lock to reroll dice I just made them reroll?
No.
Rulebook page 12: ... a die that has already been rerolled cannot be rerolled again during this attack.
It's the same with predator, right?
Yes it is. The source of the reroll does not matter.