That's a broad question. What you're really asking is how to code in HTML, CSS, and PHP or Javascript, depending on where you're storing emails and first names.
I've coded my own, which was as "simple" as taking MailChimp's raw form and then adding the HTML and CSS around it. You'd probably be better off using a plugin or paying someone to do it for you than taking that adventure yourself.
Because really, knowing how to code an optin box is the same as knowing how to code a flat file website or Wordpress theme, etc. You have to know almost all of the techniques to pull it off. It's definitely worth knowing if you have time to take that adventure but is it worth your ROI?
I took the adventure and it was a blast and definitely worth my time in the long-run. In the short-run it's a loss of time and opportunity cost. Just something to think about.