One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.
There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.
For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.
Note that this is far better than what you are doing with the
hosts file, which is an unsuitable mechanism for manipulating WWW service.