This query uses WINDOW function to get the class averages for each subject. (I am using MariaDB 11.1 but MySql 8 also has them). If you don't have then then us a subquery to get the class averages and join to that.
SELECT studentid
, subjectname
, student_score
, ROUND(AVG(student_score) OVER (PARTITION BY subjectname)) as mean
FROM (
SELECT
sc.semesterid,
sc.classid,
sc.studentid,
s.subjectname,
SUM(r.score) AS student_score
FROM result r
JOIN student_class sc ON r.studentclassid = sc.id
JOIN course c ON r.courseid = c.id
JOIN subject s ON c.subjectid = s.id
JOIN semester sm ON sc.semesterid = sm.id
WHERE sm.id = 10
AND sc.classid = 1
GROUP BY subjectname, studentid
) totals
ORDER BY studentid, subjectname;