I am a resident in Portugal, but I am not a citizen of Portugal. My residency card is not valid any more.
Can I apply for a USA tourist visa as an illegal resident in Portugal?
Sure, you can apply. Anyone can apply. However, the application form for US visas (and probably any other visa on the planet) includes a question along the lines of "Have you ever overstayed on a visa, been refused entry to a country, etc.?" If you answer yes to that and say that you're in your country of residence illegally right now, the chances of being given a visa are zero. On the other hand, if you lie and say no, then your US visa is invalid and you'd be in the US illegally, too. Since you'll be giving them your passport for them to put the visa stamp in, they will be able to see your expired Portuguese visa, so it will be obvious that you lied on your application.
Being caught lying on a visa application, especially for something so crucial as questions about how you used previous visas, is the sort of thing that gets you banned for multiple years. These questions are important because you're essentially saying, "Hi! Please let me visit your country. I totally promise that I'll leave after X amount of time, even though I said exactly the same thing to Portugal and then didn't leave." I'm sure you can see how that would affect your credibility.
So, my advice would be not to waste your money applying for a visa that you almost certainly won't get.