This question touches on the timing when an event card is played. If a runner plays Scavenge, they must trash an installed program as part of the cost. Is that program already in the heap by the time that Scavenge's effect is triggered, thus allowing the program that was just trashed to then be installed?
Short answer: Yes.
Long answer: Scavenge says "As an additional cost to play this card, trash an installed program". That means that when you play Scavenge (paying the 0 credits), you trash a program as a cost. After you have trashed the program, it then states "Install a program from your grip or heap lowering the install cost of that program by the cost of the program trashed".
Since you trash a program as part of the cost, that program is now in your heap. You then can look at the number of credits to install another program from your grip or heap - including the program you just trashed, since it is already in your heap.
You are correct, this is a fantastic way to retarget Femme Fatale, or to move an installed breaker onto Dinosaurus. The other main use is to Test Run out a breaker for 3 creits, and then Scavenge it to install it permanently for free.