Is an FAA Pilot License valid in the U.S. if held by a foreigner?
Yes. Tens of thousands of foreigners - both inside and outside the US - hold FAA certificates, including me. Your nationality is only relevant in these situations:


Foreigners must have TSA approval before starting flight training (US citizens need the approval before soloing). See this question.
Getting the TSA approval might be more difficult for people from certain countries (this is mainly a security/political issue, not an aviation one)
An FAA certificate isn't an immigration document: it doesn't give you any right to enter the US, or to work here. That means, even if you hold an FAA commercial or ATP certificate, you still need a work visa or green card in order to work as a pilot in the US. See this question.


But once you get an FAA certificate, your nationality is irrelevant. The FAA only cares about your license being "valid" in the strictly aviation sense: is your medical current, is your flight review current, is your instrument rating current etc.?

Even if you surrender your green card and leave the US permanently, that won't change anything about your FAA certificate (unless maybe you get expelled and the DHS requires the FAA to revoke your certificate on security grounds). You just send them your new address in whatever country you're in, they update their airman database, and that's it.