I just looked it up and found this pdf[0] on some technique for divers I didn't bother to understand, but it contains an instruction (Step 3: Learn to control the soft palate) how to get a feel for this. It's not really nostrils, but I think this is what GP meant.
I'm no professional diver but thinking about it and reading that link, it's really a technique to maintain enough pressure inside the nasal cavity to prevent water from rushing in, achieved by closing the soft pallet then slowly moving air into the nasal cavity as needed to maintain that pressure. So not really closing nostrils (for me at least) just restricting them a bit I think... it still sucks to get water past the nostrils but that can be prevented and it's not something I've really had to think about before. When diving into water or changing depth I have to exhale hard through the nose to combat the surge of water pressure but after that it just happens.
[0]: https://freedivewire.com/wp-content/uploads/2016/11/frenzel....