The claim isn't accurate - you won't be prosecuted for wearing a headscarf in public. However, it might be a misinterpretation or conflation of one or two things that do exist.
There is the French ban on face covering. This prohibits the wearing of clothing that entirely covers the face, unless there is a specific reason for it. The stated rationale is not to do with religion, but security and social interaction. This ban does not apply to clothing that is on the head, but does not cover the face. As such, a religious headscarf would not be banned, though a burqa would be.
There is also the French law on secularity and conspicuous religious symbols in schools. This applies to French public (government operated) schools, and bans "conspicuous" religious symbols. This does include religious headscarves. However, the ban, at least in theory, applies to symbols of many religions, not just those of Islam.