You can certainly ask any future prospective employers not to contact the previous two, however doing so is almost certainly going to come across very, very badly. Asking not to contact or avoiding using one recent employer as a reference is relatively normal and doesn't reflect particularly negatively on a candidate we all know that sometimes you just get those employers who will find something bad to say about even the best candidates, but two? In a row? That's going to raise some serious concerns and honestly I'd be hard pressed to justify taking a chance on such a candidate unless I was really struggling to find suitable people.
Since you can't exactly hop in a handy time machine and change the past though you need to find ways forward.
I think realistically you have two options at this point:
Stay where you are (for now)
Grit your teeth, get your head down and do everything you can to try and turn your current situation into one that you can be reasonably confident of getting a good reference from. I know it's going to be unpleasant and you have my sympathies for that, but think of it for short term pain for long term gain.
Proactively offer your references from further back
Some companies won't dig deeper if they are presented with acceptable references on a plate, tell them not to contact your current employer (which is totally reasonable as you can say you don't want them to know you are looking) and don't mention anything about avoiding your previous employer (doing so would only draw attention to their being something you don't want them to look at). This is dicey though - many will wonder why you don't a more recent example and the fact that they aren't from your managers will weaken their impact and there's always the chance that a company will follow up with the two you wish them not to out of their own due diligence. The upside to this option is that you can do this in parallel with the first one - if it works and you get a good offer you can take it and run, if nothing comes of it you are no worse off.
Personally I think in your situation I'd just go with option one but that's just me.
one of the top managers has asked a team lead to talk harshly to me
I do not think, talking harshly helps to solve any problem
While it's not my preferred management style I do have to admit that sometimes even good workers need a verbal kick up the arse to get them headed in the right direction and I've done it in the past as an alternative to any formalized performance management options to good effect.
it seems that my managers are highly negative about me
For what it's worth I think there's value in objectively and honestly, taking the emotion out it - evaluating your performance to see if there might be any validity to the reasons why you seem to be getting consistently bad feedback. I don't say this to make you feel bad, none of us are perfect and there's always areas we can improve and just because feedback is delivered in a bad way doesn't always mean there's no truth to it.