You might be able to do this, if all you wanted to do was see Trunk Bay. You wouldn't have very much time there.
Assuming the Doubloon trip leaves at 12:15, as is stated in the excursion docs, it would be very hard for you to get back to the ship on time. If everything goes well, you'll get to Red Hook in time to catch the 9:00am ferry. You usually have to be among the first off the ship to make it, it takes about a half-hour to get to Red Hook. The ferry trip to Cruz Bay takes about 20 minutes. The cab ride out to Trunk Bay probably another 10-15. The ferries from Cruz Bay to Red Hook also leave at the top of the hour (based on the vinow.com website), so in order to be at the ship at 12:15, you'd pretty much have to be on the 11:00 ferry. You'd get to Red Hook at 11:20(ish) and back to the ship by about 11:45. That gives you about an hour and a half on St. John, a half-hour of which would be taken up by getting to and from the beach.
It seems like a lot of work for an hour at the beach. Of course, if you don't make the 9:00am ferry, all bets are off. I'd suggest staying on St. Thomas, hitting Coki, Sapphire, or Magens Bay, then heading back to the ship for the excursion.
Good luck!