You do not have to do anything — it is built in now.
The double hat glitch became an official feature a long time ago. Simply click one hat in your inventory to wear it, then click a second. The system supports up to three hats stacked at once, and they all render together.