Is it legal to remake a videogame e.g. Team Fortress 2 theme song using 8bit style and use it in my own game? Basically, if I keep the melody exactly the same, but remake it from scratch, will I get in trouble?
Looks like it's not legal in most countries if you don't have an explicit permission from copryright owner.
A “derivative work” is a work based upon one or more preexisting works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which a work may be recast, transformed, or adapted. A work consisting of editorial revisions, annotations, elaborations, or other modifications which, as a whole, represent an original work of authorship, is a “derivative work”.
It means, your song will be classified as a "derivative work".
17 U.S.C. § 106 (found on same wikipedia page) we have following
Subject to sections 107 through 122, the owner of copyright under this title has the exclusive rights to do and to authorize any of the following:
(1) to reproduce the copyrighted work in copies...;
(2) to prepare derivative works based upon the copyrighted work;
(3) to distribute copies...of the copyrighted work to the public by sale or other transfer of ownership, or by rental, lease, or lending....
Yes, you'll probably get in trouble if you're trying to make money.
According to the USC School of Law:
The entire corpus of judicial opinions in the area of music copyright infringement dwells on melody as the single most idiosyncratic element of the works in question, and almost entirely the locus of the economic worth of a song. Accordingly, the more melodically similar two works are, the more likely a court will determine that the later created work infringes upon the earlier.
I'm not a lawyer, but you should be especially careful in this. Even if you make it from scratch, a judge could care less how you got it. If have some skill in composing, you could change the melody and add some of your own elements to the song, but if the owner finds out you could be in big trouble. Of course, if you're not trying to make money off of this, the lawyers will probably leave you alone.