Welcome to Tom's Hardware Forums!
Yes, it will work!
First backup all data from the old HDD. If you are looking to replace the HDD containing the Operating System, you must 'clone' the old HDD on to the new HDD. Then install the new HDD in place of the old HDD, and use the old HDD after formatting it (formatting will delete all data).