As a U.S. green card holder, a lawful permanent resident of the U.S., you are by definition a U.S. resident alien, not a nonresident alien.
While certain classes of visa holders who are nonresident aliens may qualify for exceptions from paying Social Security/Medicare taxes, a resident alien performing services in the U.S. as an employee is liable for U.S. Social Security and Medicare taxes, just the same as a U.S. citizen.
For more information, please see the following IRS guide, "Alien Liability for Social Security and Medicare Taxes of Foreign Teachers, Foreign Researchers, and Other Foreign Professionals":
Please check the government link
<a rel="nofollow" target="_blank" href="https://www.irs.gov/individuals/international-taxpayers/how-to-report-wage-income-paid-by-foreign-governments-or-international-organizations-for-work-performed-in-the-united-states">https://www.irs.gov/individuals/international-taxpayers/how-to-report-wage-income-paid-by-foreign-governments-or-international-organizations-for-work-performed-in-the-united-states</a>
Green Card Holders (Lawful Permanent Resident) Working in the United States
If you are a green card holder employed by a foreign government or international organization, you are not subject to self-employment taxes and may not voluntarily participate in the U.S. social security system.
@noramerkel , you said in your post you are working for a foreign company, that is not the same as a foreign government. So please clarify.