If I download a shared Playstation game and then buy it, will I keep all my progress?

PSN game saves are tied to the account you were signed in to when you play the game. So if you download the game with your friend's account, switch to yours, and play it, your save created with your account will transfer. Note, though, that you can only play the game if your friend has set the console this is done on as their primary console.