Yes you can - and yes it is.
Such is referring to the objective nature of the a sin itself.
Murder is a mortal sin.
Masturbation is a mortal sin.
Adultery is a mortal sin.
Desiring to kill or seriously wound another is a mortal sin.
Now on the subjective level - in order to “commit” a mortal sin - yes one needs not only a grave matter but full knowledge and complete consent.
The OP was asking if it was a sin and how serious of a sin it is. It being “masturbation”.
So yes Masturbation is a mortal sin (grave sin/serious sin - same thing).
Note though that I then noted that it is “grave matter for mortal sin” as well. And I provided the various links from the Catechism for the OP. Pointing to a further “unasked” question of culpability.
Is it grave matter- yes.
Is it called a mortal sin - yes. Just if someone asked me is murder a mortal sin - I can quite truly say - yes.
And yes God judges masturbation to yes be a mortal sin.
That is its nature and and we know this through his Church - which teaches that it is. So yes it is a mortal sin.
But as to the culpability of person Y - well yes that God knows best and can judge best. As to if they committed a mortal sin on Tuesday at 8pm.
A person might have engage in the said act - but due to various factors (see CCC) their culpability was reduced at that time and they did not *commit *a mortal sin (their culpability having been reduced to venial).
One distinguishes between the *objective *nature of the act - removed from the person and the subjective culpability in terms of a “particular actual act” of a particular actual person.