I have been working as a reserach assistant in an american university during my PhD study. My supervisor stopped my assistanship during a summer semester during my PhD. This was one semester before my graduation. During this semester, I was asked by another PhD student (fresh PhD student) who is working in another group to revise his paper which was under revision and give him my feedback. I revised his paper and made few formatting, and he generously add me as a co-author when he submitted the revised version to the journal. The paper is not related to my PhD work, and I used my personal computer to revise the paper. I would like to know if it is illegal to publish this paper without notifying my supervisor or not.
"Can you? Yes. Should you? No." - Federico Poloni
No, it is not illegal.
Your supervisor could be upset with you, though, either because they are merely jealous (feeling you are working behind their back) or because they view this as something that is impeding your process towards your degree.
In a healthy relationship, it would be best to let your supervisor know just to keep everything honest and clear.
It's also worth considering whether your contributions truly warrant authorship. Certainly some fields are very generous with authorship, but others expect coauthors to have had more substantial contributions than just revising the manuscript. It's possible your colleague will expect you to return the favor in the future, which could be seen by some to be inflating each of your publication records or cause conflict if your other coauthors disagree (my personal view, though, is that this sort of thing is the absolute least concerning form of gift authorship, so I feel a bit weird cautioning against it when other forms of authorship abuse are so common).
In addition to what Bryan has already said: generally speaking, you should expect that your advisor/supervisor is there to support you. Meaning they want to know how you're progressing towards graduation/finding a job so they can provide advice. If you publish another paper, that makes you more competitive as a job applicant. Maybe they want to say something in their letter of recommendation about how you're able to work with different research groups.
Towards the end of my PhD, I took some statistics courses because I wanted to be more competitive for industry jobs if I decided to go down that route. And even though this was time taken away from my research, my advisor agreed that this would benefit me. We even discussed different areas of industry I might like to research or previous students of his that I could reach out to for questions. My advisor was able to provide me this advice because I talked to him about what I was doing, what my CV looked like, what journals I was looking to submit my work in, etc.
I don’t think you have anything to worry about. In fact, chances are your advisor will be happy about what you did. On a related note advisors, professors, the department chair, etc., like to see students stay active in their chosen field. When I was a graduate student I gave some talks (at institutes and universities) about research I had done. My professors were really happy to see me make this kind of contribution. Stay active in your field and everyone around you will be impressed.