1. View > Customize Touch Bar
2. Drag "Your Message Here" button into the touch bar
3. Modify PS1 to include \[$(it2setkeylabel set status $message)\]. For example:
PS1='\s-\v\$\[$(~/.iterm2/it2setkeylabel set status $(git rev-parse --abbrev-ref HEAD))\] '
That's kind of rough because it won't do the right thing if the current directory isn't a git branch. So in practice you'll want something like
PS1='...\[$(~/bin/print_status)\]'
and a script ~/bin/print_status that outputs whatever you want to show in the touch bar, and can handle errors and so on.
To send the enter key, use the action "Send text with 'vim' special chars" and then you can use \n for newline.