Can time logged in foreign aircraft be applied towards an FAA certificate or rating?
Yes, it counts: the FAA doesn't care where flying hours are accumulated provided that the US written and/or practical test requirements are met. I learned to fly in South Africa then applied for an unrestricted FAA license (i.e. not a foreign based license). The FSDO told me that I could count all my time in SA (cross-countries, night flights etc.) towards the FAA license requirements, but I would still have to pass the FAA written and practical tests like any other student pilot.

One practical issue in this situation is that hours may be logged slightly differently in different countries, by regulation or simply by local practice. The two examples I encountered were that PIC time is (was?) defined differently in SA and the US, and the number of landings is not relevant in SA for currency so no one logs them.