You shouldn’t try this. Theoretically, a dimmer switch can control a ceiling fan but standard dimmer switches are not designed for ceiling fans. So, they can overheat easily and even fire may be caused by this.  So, for ceiling fans go for a dimmer switch that is specially designed for fans.