I recommend using the program “mandoc” (
https://mandoc.bsd.lv/) to convert a manpage from source to HTML. It was designed from the start specifically as a manpage-to-HTML converter, so it does a better job of realizing semantics from the manpage, resulting in better quality HTML than pandoc or groff. (Whereas if your target format is PDF, groff would be the best tool to use, even though mandoc has basic PDF support.) In fact mandoc is good enough that it’s installed on macOS out of the box. Once it’s been converted to HTML, you can convert that to EPUB with any of the tools that can handle that.