Print out a Drupal Commerce field only if it has a value
Content for the referenced product fields is incorporated into the product display(node) using field_extra_fields and normally contents go into the #markup key.

You can use template_preprocess_node and use something like this:

if (!isset($variables['content']['product:field_NAME']['#markup'])) {
  unset($variables['content']['product:field_NAME']);
}


You could also try Field formatter conditions module.