There is no direct train from Marrakech to Chefchaouen, but you can take a train from Marrakech to Casablanca and then change the train from Casablanca to Chefchaouen.