How to sort by condition in entityQuery
I don't think you can sort that way with an entity query.  But with a select query, you have more flexibility.

I would try something like this:

$database = \Drupal::service('database');

$query = $database-&gt;select('node_field_data', 'nfd')
  -&gt;fields('nfd', ['id']);


$query-&gt;condition('nfd.status', 1);
$query-&gt;condition('nfd.type', 'news');
$query-&gt;range(0, 5);

$query-&gt;leftJoin('field_product_category', 'pc', 'pc.entity_id = nfd.nid');
$query-&gt;addExpression('pc.field_product_category_target_id &lt;&gt; :target_tid', 'is_featured', [':target_tid', $target_tid]);

$query-&gt;orderBy('is_featured');
$query-&gt;orderBy('nfd.changed');

$matches = $query-&gt;execute()-&gt;fetchAll();