I installed the User-Agent by modifying the file ~/.w3m/configand changing the line user_agent. I have the following text, and it works as expected: user_agent Mozilla/5.0 (Linux i686; U; w3m 0.5.3; en). This one does not have: or = characters in it, so that you get an idea of the syntax used.
This is w3m version version 0.5.3.
w3m -header 'User-Agent: blah', , . , w3m, - netcat:
$ netcat -lp 9999
$ w3m -header 'User-Agent: foo' http://localhost:9999
GET / HTTP/1.0
User-Agent: w3m/0.5.3
Accept: text/html, text/*;q=0.5, image/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:9999
User-Agent: foo
2 User-Agent, HTTP-.