Posted December 7th, 2017, 02:11 PM
There may be more trains added in the summer season but going by the current schedule you could be in Cefalu by 10:11 AM (you could possibly get there at 9:22 on the train that departs at 8:27 if you are very lucky and very fast).
For the return you'll need to be on board by 4:30, so you'd need to be at Palermo Centrale no later than 4 PM to allow time for a taxi or bus (or walking, if you get desperate) back to the port.
It's always wise to take the next-to-the-last train that will get you back on time, In this case, the last train that would work would be the 3:06 PM, arriving to Palermo just before 4 PM. I think that gives you plenty of pad. The next train doesn't get into Palermo until 5:24 PM, there's a big hole in the schedule but that may be seasonal.
(note: there is an IC train at 3:40 pm that arrives to Palermo at 4:53 PM on certain days)
So it looks like you'd get four and a half hours in Cefalu, or five and a half if you make that 8:27 train.