My proposed approach wouldn’t work in this case, since the addition would create new classes.
E.g. if a specific pixel location contains a class label 1 and 2, the result would be class index 3, which would be a new class representing the occurrence of both classes.
This could be of course a valid approach, in case you want to create new class indices for the overlaps.
On the other hand, you could also use a multi-label segmentation, where the output might contain zero, one, or multiple active classes for each pixel. In that case you would use nn.BCEWithLogitsLoss as the criterion and the target would be a multi-hot encoded mask, which can be created by stacking the binary maps.
You could also stick to the multi-class segmentation use case, but would need to make sure to only keep one active class for the overlaps.