There is only one train a day between Lisbon and Madrid, and it is very slow and overnight. It's quite adequate if you get a sleeper and have a glass of wine before turning in. If you're coming in from the US into Madrid, though, you will arrive in the morning, and not leave for Lisbon till nighttime.
It may be too late for this, but if you haven't already bought your ticket, you should check the cost of adding on the flight to Lisbon from Madrid. And make your return ticket, assuming you are walking to Santiago, from Santiago to Madrid to US. It's called the multi-city option on kayak and other travel websites and you may be surprised at how cheap it is. I fly to Lisbon once a year, and I always go through Madrid -- flight arrives early in the morning, and then I'm in Lisbon by 10 or so. Taking the train will add at least another whole day, but maybe that's part of the adventure for you.
You might want to get the credential at home before you leave from the American Pilgrims on the Camino. They have a very nice credential and they send it quickly. They request a donation, but there is no charge. Buen caminio, Laurie