SELECT 
  c.category_id, 
  IF(pc.link_type = 'M', 1, 0) as is_main 
FROM 
  cscart_categories AS c 
  LEFT JOIN cscart_products_categories AS pc ON c.category_id = pc.category_id 
WHERE 
  pc.product_id = 4 
  AND c.company_id = 1 
ORDER BY 
  is_main DESC

Query time 0.00045

JSON explain

{
  "query_block": {
    "select_id": 1,
    "ordering_operation": {
      "using_filesort": true,
      "nested_loop": [
        {
          "table": {
            "table_name": "pc",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "ref": [
              "const"
            ],
            "rows": 2,
            "filtered": 100,
            "attached_condition": "((`_testcscart`.`pc`.`product_id` <=> 4) and (`_testcscart`.`pc`.`category_id` is not null))"
          }
        },
        {
          "table": {
            "table_name": "c",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "_testcscart.pc.category_id"
            ],
            "rows": 1,
            "filtered": 100,
            "attached_condition": "(`_testcscart`.`c`.`company_id` = 1)"
          }
        }
      ]
    }
  }
}

Result

category_id is_main
3 1
1 0