Yes you can do it but it will be a rat race.It depends on how long your in port. Pompeii takes a good 4 hours to see most of it figure 1/2 hr by train which stops quite near entry. Ferry to Capri is appx 1/2 hr each way buy your return ticket as soon as you get there to ensure you get on boat you want to return on.
Better to choose one site and enjoy it.