A molecular mechanism for probabilistic bet hedging and its role in viral latency