The command port interface can be used to change the gain value. There is an example of creating messages for tuning included in gr-uhd.https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/grc/uhd_msg_tune.grc
I've used a function probe to generate coarsely timed "tick" messages to a custom python block which is correctly formatting the messages before. Unfortunately I cannot find that GRC file at the moment. The function probe will run at an approximate interval dependent on your system and GNU Radio's scheduler. If you don't need exact timing then just use the gain message and function probe, if you do need exact timing include both time and gain values in the pmt command message then the gain will be applied at the specific time based on the radio timestamp. Set the Sync setting to unknown_pps, which will set the radio timestamp to 0 when the flowgraph starts, and set the initial timestamp for the command port message to a second or two in the future to account for the startup time of the flowgraph.