As far as I know, there isn't a way to prevent a turret from attacking an enemy unit if it is within range and there are no other targets. Well, you can power it down, but I assume you'd like it to still kill AI units.
The only reason I can think of that you might want to do this is if you wanted to control where the AI's reinforcements spawn... but even then, it is usually better to kill all the Guard Posts (and Wormhole Guardians, too, if you can) and let all the reinforcements spawn at the Command Station. That makes beachhead layout much simpler.
What are you trying to accomplish?