I have tried creating the code below but it didn't work for me.
what I'm trying to do is use Row_number however check if the column MP =' Yes' then +1 to the Row_number value if it does otherwise just give me the Row_number.
SELECT
[Key]
,[Key2]
,MP
,OriginalOrder = ROW_NUMBER() OVER(Partition by [Key] ORDER BY [Key],[Key2])
,IIF(MP = 'Yes' , ROW_NUMBER() OVER(Partition by [Key] ORDER BY [Key],[Key2])+1,ROW_NUMBER() OVER(Partition by [Key] ORDER BY [Key],[Key2]))what_i_have_tried
FROM
cte_RowNumbertest
ORDER BY
1,2

If I understand correctly, you can try to use
SUMwindow function withCASE WHEN, ifMPis yes add one more.