A friend of mine is sharing a game with me on Steam, which I will happen to be buying for myself later on. But, when I buy/activate the game on my library, will it be replaced with the shared one or will it keep telling me that the game is being shared?
When you activate a game on Steam that was previously being shared with you, it will cease to be counted as a 'shared' game. It's now in your own library as a game that you bought for yourself, so you no longer need to worry about the game having 'shared' status from your friend.
However, as Sergii Zaskaleta has pointed out, if there any DLCs that your friend owns for the game but you don't, you lose access to those and you'll only have the base in your library. As Asunez then went on to point out, this may mean that depending on the game, any save files you have on it that depended on the DLC may be rendered unusable and can be used again when the DLC is purchased.