Will be based in Salerno, taking the train to Naples to see Naples and Capri. Are Naples and Capri doable in one day?
They wouldn't be doable in one day even if you were staying in Capri or Naples (instead of Salerno). Naples is a huge city (lots to see there), and Capri requires a ferry to get to (so you have to factor the ferry schedule times in as well).
Even from Positano ( which I think is closer than Salerno to Capri) we needed a full day to get a taste of Capri. We used the RS guide book, did not go to the blue grotto, and still spent a full day there.
We stayed in Sorrento, just a walk to the ferry to Capri, and needed the whole day for a quick visit to Capri.
On a separate day/night, taking the train to/from Naples, that also needed the whole day, lasting into the evening. The Archeological Museum in Naples alone, which displays lots of amazing, surviving parts of volcano-buried Pompeii, needs a lot of time.
Only if you have access to the Star Trek transporter system
Scotty, ready for beam up....
The ferry from Naples to Capri takes about an hour each way. Adding in your time to travel to and from Salerno plus see Capri you won’t have much time to see Naples also. I’d choose either Naples or Capri. Are you seeing Pompeii on this trip? If so, you’d probably like to see the archeological museum in Naples too. You could make a day of the museum and Pompeii in one day. Remember, the museum is closed Tuesdays. Naples has a lot to see in a day. And of course you should have pizza!
No, both cannot remotely be done in a day. Note that seasonal schedules, sunset, and weather affect ferry schedules. Same answer for sleeping in Sorrento.
In season, Salerno may have a Capri ferry. You could leverage your time by spending a night in Naples, but it depends on how long the whole trip is.