ignore_index will ignore valid as well as invalid target indices.
E.g. if you are dealing with 10 classes, your model output would have a dimension of [batch_size, 10] in the vanilla multi-class classification setup, while the target will be a LongTensor of shape [batch_size] containing class indices in the range [0, 9].
If your target contains any other values outside this range, you’ll get a RuntimeError:
RuntimeError: Expected cur_target >= 0 && cur_target < n_classes to be true, but got false.  (Could this error message be improved?  If so, please report an enhancement request to PyTorch.)

Now, if you specify a special class index in ignore_index, your target might also contain this index without throwing an error.
On the other hand, setting a weight of zero to a specific valid class, will create zero gradients for this class logit.
Setting ignore_index to the same valid class will yield the same behavior.
While the use cases might be different, if you use a valid class index for both approaches, you should see the same result.