The marriage would be lawful, assuming they meet the other legal requirements of the jurisdiction in which they marry (being of legal age, residency requirements, etc.)
If the question is also, whether the F1 student would be able to eventually become a legal permanent resident if they marry, then the long-term answer will generally be yes, but it can be a long process and the F1 student would want to remain in legal status in the interim.

