It is too late to replace Trump on the ballot. Voting has already started in some states. In others, the ballots have already gone to the printer. But Rick Hasen notes an alternative
But if Trump withdraws, and in fact even if he doesn’t, there is one other possible way out: the Electoral College. When we cast our votes for president they are actually cast for electors from each state (based roughly on population size) who then cast ballots for president. If Trump is chosen in some states, those electors could vote for Pence, or Romney, or Kasich, or whoever. There are some laws that bar “faithless” electors from casting votes for anyone who did not win the popular vote in a state, but I have a hard time believing either the Republican-controlled House or a court (because it raises a political question) would stop the actions of a faithless elector. Ned Foley games out how conflicts would work under the Twelfth Amendment; the bottom line is that if Trump got more votes than Clinton and Republicans control we could well end up with a President Pence. (When no one gets a majority in the Electoral College the House votes on a one state delegation, one vote rule.)
The reason this is such a Hail Mary is because it depends on a huge number of unlikely contingencies: Trump withdraws or the Republican leadership abandons him yet still get voters to choose Trump on the ballot, the “Trump” campaign gets more electoral college votes than the Clinton campaign (requiring a lot of thinking and effort on the part of battered voters), electors chosen by the Trump campaign to serve the Republican ticket (some of whom LOVE Donald Trump) would act faithlessly and vote for Pence or someone else, and Republicans control the Senate. All of this is possible, but not bloody likely.