You could write a custom transformation using the functional API es described here 55.
You could pass the desired ranges for gamma and gain, sample these values randomly in the __call__ method, and apply them on your images.