I'm in favor of opt-in for something like using location data (info the government doesn't normally have because it is private companies with the info, at least in the US), but it won't work at all for limiting pandemic response, because someone that doesn't opt-in can spread the virus.
So even if everyone else opts-in and allows location usage (perhaps time-limited or whatever) to fight this pandemic, it just takes one infected person to opt-out and destroy containment efforts. Just like South Korea's patient 31.
I can't think of a general solution for this, for a case where full cooperation is needed. If it is crossing a very big red line to interfere with freedom of assembly in the midst of a pandemic, then one tool I can think of is to charge/prosecute people that take risks that cause harm to others. Not just a fine, rich people could effectively ignore restrictions. I mean serious charges, attempted murder or assault for every other person they infect.
You want to unlimited freedom, then take unlimited personal responsibility for the harm you cause.
The other solutions are to split hairs somewhat. The 1st Amendment only prohibits Congress, so delegate to the States to forbid assembly in pandemics. But, not being an attorney, I don't know if that legal strategy flies.
Another is language lawyering, the 1st Amendment specifically mentions "the right of the people peaceably to assemble". Obvious workaround is to consider an infected person not peaceful, they are after all, attacking everybody around them with trillions of microscopic invaders. You can gather only if you can prove you aren't infected.