I have few papers already published in certain journals which cannot be uploaded on ResearchGate due to copyright issues, now is it legal to upload my own version of the paper formatted in LaTeX or in other words the manuscript I sent for publication that was not typeset for journal publication?
In general, the typesetting is irrelevant, as far as copyright law is concerned; the law protects the content, not just the specific file. If posting an exact copy would infringe copyright, then posting a re-typeset copy would also. If the publisher owns the copyright, then you need their permission to upload anything that contains any significant amount of the paper's content (barring fair use exceptions, etc).
Some copyright agreements contain terms saying that they only cover the journal's typeset version, giving the author permission to self-archive their own version. But if yours said that, you would know.
For a more certain answer, consult an intellectual property lawyer in your jurisdiction.