A friend can potentially give you money for a mortgage, depending on your relationship with that friend and the type of mortgage you plan to apply for.
For conventional home loans, Freddie Mac permits gift money that comes from “an unrelated individual with close, family-like ties to the borrower.” Other types of home loans also allow gifted funds from a friend, as long as the friend does not have a financial interest in the transaction.