$r$-process Nucleosynthesis and Kilonovae from Hypermassive Neutron Star Remnants