Compute the interpolation factor between the SLERP of 2 quaternions, given those quaternions and the SLERP result
We can do this mostly by measuring angles between the quaternions, with a bit of sign flip to get the orientations right. Angles between normalized quaternions are given by the arccos of their dot product (as a 4D vector).
$$
t = \frac{\arccos(q_1 \cdot q)}{\arccos(q_1 \cdot q_2)} \ \text{sign}\bigl(q \cdot [q_2 - (q_1 \cdot q_2) q_1]\bigr)
$$
The first factor is measuring the angle from $q_1$ to $q$ as a fraction of the angle from $q_1$ to $q_2$. This ensures that $t$ will be 0 at $q_1$ and 1 at $q_2$. The other factor ensures that $t$ increases as you move from $q_1$ toward $q_2$ and goes negative on the other side. The quantity in brackets is the projection of $q_2$ on the (hyper)plane perpendicular to $q_1$, then we're dotting $q$ with that to decide which side of the circle we're on.
Note that the point where $t$ swaps from negative to positive will be the point opposite $q_1$ on the circle—not a point centered across from $q_1$ and $q_2$ as your diagram has it.
(Also, it's worth noting that this boils down to essentially the same thing as the logarithm solution in the other answer. Their factor $\check p/\|\check p\|$ corresponds to our sign factor: all the quaternions in the problem are in the same plane and so will have $\check p$ along the same axis; the only thing that can differ between the normalized $\check p$s is the sign.)