Field weight in display mode is not respected on custom entity
After debugging the Drupal\Core\Field\FormaterBase on how the fields getting rendered, it seems the weights are getting applied to each field in Drupal\Core\Entity\EntityViewBuidler, but they are not getting rendered in the order at the entity level.
So providing a theme for the entity using hook_theme and a preprocess solves this issue. Here is the code:
// mymodule.module

use Drupal\Core\Render\Element;

/**
 * Implements hook_theme().
 */
function mymodule_theme() {
  return [
    'myentity' =&gt; [
      'render element' =&gt; 'elements',
    ],
  ];
}

/**
 * Prepares variables for myentity templates.
 *
 * Default template: myentity.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - elements: An associative array containing the entity
 *     information and any fields attached to the entity.
 *   - attributes: HTML attributes for the containing element.
 */
function template_preprocess_myentity(array &amp;$variables) {
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}

&lt;!-- myentitty.html.twig --&gt;
&lt;article{{ attributes }}&gt;
  {% if content %}
    {{- content -}}
  {% endif %}
&lt;/article&gt;