The Mac’s Touch Bar is actually a second, mini-display. Which means you can take a screenshot of whatever it’s displaying.
By default, ⇧⌘6 (Shift, Command, 6) will save a screenshot of Touch Bar as a file on your desktop. Alternatively, pressing ⌃⇧⌘6 (Control, Shift, Command, 6) will copy what you see on Touch Bar to your clipboard for pasting in an app.
You can customize which keyboard shortcut does what by going to System Preferences → Keyboard → Shortcuts → Screen Shots and selecting the key combination for both Touch Bar shortcuts.
You can also create a button on Touch Bar’s Control Strip for creating screenshots of your Mac display. Go to System Preferences → Keyboard → Customize Control Strip. Drag and drop the screenshot button where you want it on Touch Bar.
(This how-to is based on my experiences and info on Apple’s support pages — where the images sometimes come from.)