Query with custom sorting
The easiest way is to hold reference to itself in the duplicate_with for the master records while their is_duplicate fields contains zero. Then all the group (master and all its slaves) can be extracted by duplicate_with field value:

SELECT * 
  FROM sample
 ORDER BY duplicate_with ASC
        , is_duplicate DESC
        , id ASC
;


If you can't for some reason update master records then you can do the same by joining table with itself:

SELECT z.id AS id
     , z.is_duplicate AS is_duplicate
     , z.duplicate_with AS duplicate_with
     , z.name AS name
  FROM sample AS w
  JOIN sample AS z ON z.duplicate_with = w.id
                   OR z.id = w.id
 ORDER BY w.id ASC
        , z.is_duplicate DESC
        , z.id ASC
;


Sure that approach can be significantly slower on the big tables.