The legal requirement is that at least one of you has to be resident in France for a minimum of 40 days continuously, immediately preceding the marriage. This must be in the town where the marriage is to take place.
That being said it is worth mentioning that in some very special cases, those with property or that have family with property in France have been allowed to marry without having to follow the residency requirement. However this is at the complete discretion of the Mairie so it can be worth contacting them directly.
What most couples do is sign the legal papers at the registrar of where they live prior to the marriage ceremony in France. Keep in mind though that for most of your guests the “real” wedding will be the one in France.