I was given a mouse by someone who now i realized would want to hack me. It is the Microsoft basic optical mouse v2.0. Can this mouse be modified to inject spyware and malware onto my laptop?
The USB protocol allows to emulate mass storage which you then need to run from manually in order to get hacked, so it's unlikely you could have missed it.
But even without a built-in ROM this mouse could possibly send all your mouse actions via radio channels which is enough to infer a lot of information about you.
Another avenue is a vulnerable USB stack in your operating system but if you keep your software up to date it's highly unlikely you could have been hacked this way.
AFAIK USB4/Thunderbolt is a whole different affair as it can function as a PCI-E device with full DMA control over your system (meaning full read access to your RAM without your OS knowing anything about that) but USB4/Thunderbolt devices are still relatively rare and Intel claims modern operating systems have safeguards against this.
Yes, it is possible!
A full up custom device that looks like a Basic Optical Mouse would require a fair amount of technical resources and money.
A more Do It Yourself approach might use something like The O.MG Adapter either embedded in the mouse, if there is room, or permanently attached in-line on the cable. It runs around $200 and still requires some significant technical expertise. Only you can decide how likely that is in your circumstances.
Can this mouse be modified to inject spyware and malware onto my laptop?
If I were you, I wouldn't expose my computer to any risk by using a mouse given to me by a person that wants to harm me. I would ditch the mouse and buy a new one, just to be on the safe side.