The best way to implement this is using departments (combined with agent permission groups) rather than teams.
Say you have Agent Group A and Agent Group B, and neither group should be able to see the other's tickets. You would create Department A and Department B, give Group A permission to view Department A only, and give Group B permission to view Department B only.
You could then use triggers or manual assignment by another agent to send tickets to the right departments. See Limiting agent access to tickets by department for more details.