There is no legal limit to how many people can be on a mortgage, but your lender may have restrictions in place. Remember that everyone on the loan also has to be able to qualify for it to be approved, and some lenders may see a big group of names as a potential risk.
Even if multiple people aren't on a loan, keep in mind multiple parties can still own a property through joint tenancy or tenancy in common.