JPEG images are nearly always already white-balanced. This means that 1 or more channels may have already clipped as part of the process. Changing the WB afterwards cannot "undo" the clipping (the clipped data is gone).
The other aspect is that WB is really best performed on linear data. Otherwise you'll get uneven white balance effect across the tonal scale. But JPEGs are no longer in linear form, and it is not generally possible to get the data back into linear form.
Let us assume that jpeg produce sRGB data (it does not, but the conversion from YCbCr->sRGB is initself lossless or practically lossless)
[r,g,b] = [m00 m01 m02;m10 m11 m12; m20 m21 m22]*[ri+rioff,gi+gioff,bi+bioff]
for each of r,g,b
ch = ch + offset
ch = clip(ch, min, max)
ch = nonlinear_function(ch) + noise
My 3x3 matrix is thought to contain color correction, WB, saturation, exposure correction etc. The clippers limit black point and white point. The nonlinear function is any tonemapping/gamma that stretch levels. The noise contains roundoff errors, JPEG quantization errors etc.
-the nonlinear function is approximately invertible (I believe that gamma functions tend to be),
-the noise is not too high
-the clipping affects relatively few samples and/or with a small change
-the linear 3x3 matrix has an inverse
Then I believe that a one can do an inversion that might have practical application (even though it will be a non-perfect one)? The problem usually is that the handful of parameters needed to do the inversion are unknown and practically impossible to estimate blindly.
(my model is based on my own limited understanding and how I believe it applies to only the problem of white-balancing jpeg files.)