A Unified Approach to Synchronization Problems over Subgroups of the Orthogonal Group