It can be grammatically correct to start a sentence with the infinitive. "To be or not to be?" is an example that comes to mind. Or you could say something generally like an axiom or a philosophical point like "to learn is to grow" or something like that. Or you can start a sentence with a clause like "to be fair, it wasn't really that cold." These are a few examples I can think of off the top of my head.
I'll add that "to swim" is not correct here. But I can't really tell you exactly why. If you said "to swim at this beach is not allowed after 6 pm" to a native speaker they would probably understand you, but it's definitely not a natural way of saying it.