The answer to this question is no; with maybe a couple of exceptions; but these exceptions are rare cases that probably don’t apply to most situations. If the “beach” in question is a river bed where fresh, non polluted water flows, then the sand there may be ok; but it is a big risk to use it. For one, most pristine river beds are protected and removing sand may be harmful to the ecosystem and against the law. There could be any kind of bacteria present in the sand there, and it would take disinfection and testing to be sure the sand was clean.
If the “beach” is on a fresh water lake with no public use and limited access to human use, then maybe the sand would work. There would still be the danger of contamination from zoonotic organisms (this also applies to the river bed sand mentioned above).
If the “beach” is an ocean beach, then there will be salt in the sand which is totally unacceptable, and furthermore if the beach is a place where there is lots of “use” then there could be anything in the sand – anything – including salt. Think about it: dogs, horses, people, all who have walked almost anywhere . . . need I say more? Do not EVER use sand from a public ocean beach in a water filter.
Another problem with “beach” sand is lack of uniform size of the individual grains.
See this previous post for sand source suggestions.