Rule of thumb is "trust people...but don't".
You never want to leave something in a hostel you do not have a plan to replace.
The more robust your plans, the more you can leave behind.
Absolutely, use the lockers and have your own padlock. If your onebag will not fit in the locker, unpack its contents into the locker, then shove the bag inside if it will fit. Otherwise, leave it on the bed, maybe leash it to the bed so no one tries to "claim your bunk".
But, in general, hostels are pretty safe for theft except when they're not.
What you really are trying to protect against in a hostel is not theft, but "sticky fingers".
Remember: A padlock, to a determined thief, is only a deterrent. It is never security. Look up how to shim a common combination lock with a soda can.
Your best security is to get a good spider-sense about your room mates, and if needed, create a reason to ask for a room change. You want to prevent access...because there is only so much you can do to prevent full-on theft.
And, obviously, take as much with you leave the room as is practical.
e.x. I'm okay losing my clothing and even my bag...but I take my laptop, passport, extra cash/cards, etc. with me everywhere. I leave a back-up credit card in the room in case I get mugged -- split your resources.
If you do leave your laptop in a hostel locker, just have a plan on how to secure a new one, have good back-ups, have a "find my" app installed, etc.
. . . . . .
Something I've done before is travel with tamper resistant seals. You use them in addition to your padlock. What they do is remove the ability of the attacker to "cover their tracks" as easily -- won't stop a determined thief, but it will deter sticker fingers.
I always keep a few in my bag. They're pretty cheap in bulk.
https://www.amazon.com/Plastic-Numbered-Extinguisher-Security-Disposable/dp/B086H3FQNX/
THESE stupid little plastic things have saved me so much hassle, can put them on everything a human needs break glass access for without pissing off the fire marshal, and they do an amazing job of keeping out morons
https://www.amazon.com/dp/B086H3FQNX/ref=cm_sw_r_cp_apa_glt_fabc_AZTTTQQHBSDDWDYECE4C?_encoding=UTF8&psc=1. Numbered tags would make it difficult to fake