Yes it is
Imam Shafi’i stated that masturbation is forbidden based on the following verses from the Qur’aan (interpretation of the meaning): "And those who guard their chastity (i.e. private parts, from illegal sexual acts). Except from their wives or (the captives and slaves) that their right hands possess, - for them, they are free from blame. But whoever seeks beyond that, then those are the transgressors." 23.5-7 Here the verses are clear in forbidding all illegal sexual acts (including masturbation) except for the wives or that their right hand possess. And whoever seeks beyond that is the transgressor.
https://islamqa.info/en/329