Usually the rule is you can't have a phone out of your pocket or backpack during a test. Students still have phones on them. If they disallowed that too, how would that work, an airport security style check going in?
Yes, that kind of thing can and is done, if the stakes are high enough.
If NYC schools can do it at scale (1,600 schools this year banned cell phones), Princeton could certainly do it.
Students either leave phones at home, or the school provides pouches/mini lockers for each student.