I can follow this script to show or hide hidden files on a mac, it works. Is there a way to add an icon to the finder window that on click toggles this functionality?
http://www.techiecorner.com/153/how-to-show-hidden-files-in-finder-mac-os-x/
Some ideas:
Make a double-clickable AppleScript file with above commands and drag the icon into your sidebar or top window bar. This article might help.
Use the Secrets PrefPane to un/set Finder → Show hidden files
Use the hiddenfiles Dashboard Widget