Analytic gradients in variational quantum algorithms: Algebraic extensions of the parameter-shift rule to general unitary transformations