Now this is a nerdy, overcomplicated solution that I like.
Let's Encrypt makes this pretty easy, and free. What I usually do is have localhost.foobar.com resolve to 127.0.0.1, and either have a Let's Encrypt wildcard cert, or a cert specifically for localhost.foobar.com
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.