I assume that what you mean is that when a user types www.example.com into the URL bar and hit return, it will be changed to example.com.
Assuming that is what you mean, the ONLY way to accomplish this is with a rewrite. And the only way to accomplish this is with a web server. There's nothing you can do with DNS to accomplish this.
User's browser sends a GET to a web server. Web server sends back a "301, moved permanently" to the browser. Browser updates the URL bar and sends a new request.
Note, however, that I said *a* web server. It doesn't have to be the same web server that you serve your site with.
Many DNS providers offer a "redirect" service. This is where the confusion comes in, and causes the erroneous notion that DNS has some redirect capability - it doesn't. The DNS provider has a web server set-up specifically to do redirects.
So, see if your DNS provider (most often your registrar) offers this. Since this is not actually a DNS feature, but an additional service offered as a convenience by the DNS provider, it's hard to give exact advice on how to do this, since the implementation varies from provider to provider.