Cosmo and the Pirates by Daniel Postgate
Amateur ghostbuster Cosmo Jones is called in to Mario's Pizza Restaurent to investigate claims of spooky goings on. He hears strange noises coming from the jukebox and soon faces a ghost ship complete with pirates! This is the second book in THE SPOOKY WORLD OF COSMO JONES series.