Assuming that both of the above sections (forearm and upper arm) are of the same length
Then let 1 unit of our coordinate system be the length of one arm segment. Let's also assume the joint quaternions we have are arranged so they point a unit "forward" vector along the length of the bone.
elbowOffsetFromShoulder = shoulderRotation * forward;
handOffsetFromShoulder = elbowOffsetFromShoulder + shoulderRotation * elbowRotation * forward;
Now we can form a quaternion that orients the forward vector to point from the shoulder to the hand with a LookRotation convenience method. This still leaves us with one degree of freedom: the twist of the rotation about the shoulder-hand line. We can arbitrarily choose to try to align the up vector of our resulting rotation as close as possible with the shoulder's local up.
shoulderToHandRotation = Quaternion.LookRotation(handOffsetFromShoulder, up);
If you're in an engine like Unity you'll have a convenience method like this already. If not, you can implement your own version, or construct a matrix with the desired orientation (
eg. column 3 = normalize(handOffsetFromShoulder), column 2 = normalize(up - dot(up, column 3) * column 3, column 1 = cross(column 2, column3)) and convert the matrix to a quaternion.
Note that this quaternion generally points in a different direction than the forearm's orientation, so if you then stack a hand or pointer with a particular orientation on the end, it will need adjustment to stay aligned with its new parent, ie.
newHandRotation = Inverse(shoulderToHandRotation) * shoulderRotation * elbowRotation * handRotation;