Hi there,
It is possible to do LA to San Francisco on trains but not on one service.
The Amtrak Coast Starlight, see
richardderby links above takes you from Union Station is LA up to San Jose. That takes the day, 10am to about 8:30pm.
You can then get a
Caltrain up the west bay through Palo Alto, Menlo Park, past SFO airport and into San Francisco.
Link (pdf) to the timetable.
I did the trip a few years ago. I flew into LA, stayed in an airport hotel that night and got the LA metro to Union station in the morning. It was then a day's ride along the coast.
Let me stress this bit:
It's a great trip!
You leave through the mad suburbs of LA, past Burbank airport and go up and through the LA mountains. You then drop down to the coast and go along the top of beach through Santa Barbara and then there's a trip through Vanderberg US Airforce base.
Then its onto the central valley which isn't the most interesting bit to be fair but it's a got to late afternoon and it's an excellent moment to check out the beer offerings in the restaurant car.
The bit around King City is dreadfully boring unless you like looking at cabbages but fortunately there's a lot of freight traffic to look at.
Then once past Salinas you start to get to the outer suburbs of San Jose and the start of the whole built up area.
You need to change trains at San Jose unless you want to carry on to Oakland, Sacremento or other places north.
Or since it'll be dark, stay in San Jose and check out the rather good brew pubs and the go on to San Francisco the next day in daylight.
Cheers,
Mr Toad