I think the common use case would be to use it during the training only.
The validation dataset should act as a good proxy for the final model performance on the unseen test data. So I would try to keep the data distribution of the validation and test datasets as close as possible.
Since your test dataset is also imbalanced, using weighted sampling on it might not give you a proper signal how your model would perform on real world data (which should also be imbalanced).
However, that’s my biased opinion so let’s wait for some other opinions.