Synergy as a warning sign of transitions: The case of the two-dimensional Ising model