I'm not particularly familiar with PHP, but after you set the variable can you check to see if it has a value? If there is no hubspotutk value, you shouldn't include it in the form submission.
If the form is being posted from an ingocnito browser, it's possible that the visitor doesn't have a hubspotutk cookie. While this should not cause a 500 error response from HubSpot, it's possible that it's causing an error in your code since you're explicitly setting the $hubspotutk variable. Can you try the submission in an incognito window after confirming that the hubspotuk cookie exists using the Chrome dev tools?