Would this work?
batch_size = 2
model = nn.Linear(20, 16)
x = torch.randn(batch_size, 20)
y = torch.randn(batch_size, 16)
criterion = nn.MSELoss(reduce=False)
weight = torch.ones(16)
weight[1] = 3

output = model(x)
loss = criterion(output, y)
loss = loss * weight
loss.mean().backward()