Generally the headset is properly installed by the builder where the bike is manufactured and the bike shop just checks to make sure it is adjusted correctly. The handlebars are not on the bike but rather along the side of the bike held on with zip ties.
The bike shop, during assembly, should check the headset adjustment during the build process but perhaps it was not and there is an issue.
Generally it is a straight forward setup and if the headset has a problem either with the head tube area, headset bearings or both it is apparent from the start and generally it is not an intermittent problem.
This is a weird one and I wish I could get my hands on it to try to figure out what is wrong...an interesting problem.
Good luck...take it back to the shop...