Currently, I am working on a custom form that generates products on the fly for a custom purchase order implementation.
For this Drupal 8 commerce website, the product variations have a required weight field which was needed in the custom form.
Here is an example of the weight field.
$form['product']['weight'] = array( '#type' => 'physical_measurement', '#title' => t('Weight'), '#measurement_type' => 'weight', //the default field is required and must be an array. '#default_value' => ['number' => 2.00, 'unit' => 'oz'], );