The instrument used for this purpose is known as Salinometer and it measures the salinity of water based on scientific concepts. Now we normally are under the impression that water is a good conductor of electricity and hence we are always advised not to touch electrical appliances with wet hands and so on. Of course I am not going to change that advice here but I want to tell you that the purer the water, the less conductivity it possesses.
Sea water on the other hand contains lots of impurities such as sodium chloride, magnesium chloride, calcium chloride and so forth. The chlorine ions help in conduction and hence these impurities increase conductivity of water.
You must have intuitively realized by now that if conductivity varies with purity the reverse is also true. It therefore means that measuring conductivity of water could give an indication of its purity. Infact this is the very principle which is used in a Salinometer.
One important assumption made in a Salinometer is that the conductivity is mainly due to sodium chloride and the effect of other impurities is ignored. This may not give a very accurate reading of purity but is good enough to indicate the purity for practical purposes on board.