Would concatenating the input with another tensor during the forward pass work?
torch.manual_seed(2809)

lin = nn.Linear(10, 1)

x = torch.randn(1, 9, requires_grad=True)
constant = torch.zeros(1, 1)
data = torch.cat((x, constant), dim=1)

out = lin(data)
out.mean().backward()

constant = torch.ones(1, 1)
data = torch.cat((x, constant), dim=1)
out = lin(data)
out.mean().backward()

print(x.grad)
print(lin.weight.grad)