Hosting a domain in localhost

Is it possible to host a domain in localhost??

like .net .org .com in localhost??

Yes, this can be done if you’re using a local DNS resolver. On systems using systemd, the default resolver would be systemd-resolved.

Alternately, you could use another DNS resolver, like Unbound (which I use). For the exact configuration, you will have to consult the documentation of your chosen DNS resolver.