How do I remove an iMessage account from OS X (Yosemite) Messages app?
OK, I figured it out but it's not straightforward. I figured it had to be stored in a .plist file somewhere, so I searched all the .plist files in ~/Library/Preferences for ones that contained the Apple ID I used for iMessages. These were the ones:


com.apple.ids.service.com.apple.madrid.plist
com.apple.ids.service.com.apple.private.alloy.sms.plist
ByHost/com.apple.identityservices.idstatuscache.5A488A33-7FF1-56F5-A3F6-CBC792D5C705.plist


When I searched for com.apple.ids.service.com.apple.madrid.plist on the web I found a link to a very useful answer on the Apple forums that also helped out.

So basically, this is what I did:

Delete the .plist files I mentioned above (note, the last one with the UUID in the name is likely to be different for each user):

cd ~/Library/Preferences
rm com.apple.ids.service.com.apple.madrid.plist
rm com.apple.ids.service.com.apple.private.alloy.sms.plist
rm ByHost/com.apple.identityservices.idstatuscache.5A488A33-7FF1-56F5-A3F6-CBC792D5C705.plist


Then I removed all the chat history and archive:

rm ~/Library/Messages/chat.db*
rm -rf ~/Library/Messages/Archive
rm -rf ~/Library/Messages/Attachments


Then I restarted the Mac just in case. Now the account and everything about it that ever existed on this machine is gone :)