Sin? Jesus wasn’t talking about ‘sin’. He was talking about Judging - judging yourself. And that certainly is not (a) sin. The context is clear. We see it in the previous verse.
MAT 7:1 Do not judge, or you too will be judged. 2 For in the same way you judge others, you will be judged, and with the measure you use, it will be measured to you.
I appreciate some may want to argue whether ‘judging’ others is a sin or not, and then ‘add’ that context into this passage - but the fact is that is not the focus or point of what Jesus was saying.
On other occasions, Jesus told people to judge (Luke 12:57 and John 7:24). The disciples told people to judge (Acts 4:19; Romans 14:13; 1 Corinthians 5:12, 6:2, 10:15, 11:13, and 14:29). Paul judged (1 Corinthians 5:3 and 2 Corinthians 5:14). There are many examples of people judging. Paul prayed that our love would abound more and more in all judgment (Philippians 1:9).
In the light of these scriptures, it is evident that there must be a right and wrong type of judging - and that is the focus of this passage - it’s not about ‘sin’.
It is the condemning, or rather pointing out the type of judgment that is wrong. Also notice that in these scriptures, Jesus was not forbidding judgment; He was warning us to be careful with our judgments because we will be judged accordingly.
This same principle is stated in Romans 2:1-3 and James 2:12-13. There are certain cases where we have to pass a condemning sentence, as Paul did (1 Corinthians 5:3-5 and 1 Timothy 1:20). This warning constrains us to be certain that we ‘judge’ righteously, and are not simply venting our own frustrations.