They can tell you that, yes. They have no legal authority to force you to do so, but they can tell you just like they can tell you to put it away just like they can tell you to go jump in the lake.
What will happen if you don't? A number of things, ranging from an unpleasant chewing-out while they attempt to intimidate you into complying, right up to pulling guns, dog-piling you, and arresting you.
Legal? No. Consequences? Almost none for the individual officers involved.