I don't see why it wouldn't be possible! It would just depend on how long it takes you to run the 5k, if you want to hang out after the 5k, and if you want to go back to the hotel and shower. I think you should be ok though!
If it takes you, say 45mins to finish the 5k...that's still ending at like 7:45am or 8am. Then you have an hour and a half to do whatever and meander over to Cape May!