Do not run this code on posts with a specific tag!

This is more of basic PHP. You are correct in choice of function, you merely need to reverse the condition with logical Not operator:

if( !has_tag('test') ) {

}