I think inplace is the best way, but I’ll throw in a .clone(), so you get to keep the input:
a = torch.randn(5,4,4, requires_grad=True)
b = torch.randn(5,1, requires_grad=True) 
c = a.clone()
c.diagonal(dim1=-2, dim2=-1)[:]  +=  b

# backward works as expected:
c.sum().backward()
print(a.grad, b.grad) # ones_like(a) and full_like(b, 4)

Best regards
Thomas