You can expand the weights for a segmentation use case:
input = torch.rand(1, 3, 2, 2)
target = torch.round(torch.rand(1, 3, 2, 2))

weight = torch.tensor([1., 1., 1.]).view(1, 3, 1, 1).expand(-1, -1, 2, 2)

criterion = nn.BCEWithLogitsLoss(pos_weight=weight)
loss = criterion(input, target)

The implementation of binary_cross_entropy_with_logits can be found here 5.