One way to do it is to use a kit as pictured below. They are sold through a lot of vendors that cater to classic cars that came with low-back bucket seats. You weld or otherwise attach the bracket to your seat frame, and the headrest "legs" just slide into it. You can do something similar and much cheaper with junkyard or eBay parts.