A gradient is defined wrt some operations, it has a precise mathematical signification.
There is no point to manually modify it. You may want to modify the usage of the gradient while, for example, setting the gradient descent (in that case you can do something inheriting from torch.optim.Optimizer)