If the razor clam is open, you can touch it lightly with your hand to see if it will close. If it does, it is alive.
Generally, you can also look at the water. If it is very dirty, it means there are dead razor clams. You can also smell it.
It is best not to eat dead razor clams.
The external dirt can be removed with a small brush, but there is no way to remove the internal sediment. For fresh razor clams, you can add a small amount of salt to the water so that the razor clams can spit out the sediment.