...can I do a time machine backup of my current hard drive on an
external hard drive, install the SSD, and then use the time machine
backup from the external to transfer it onto the newly installed SSD?
Yes. This is a valid and accepted backup/restore technique. The advantage here is you don't need to worry about size differentials of the two drives (larger HDD than your SSD, for example).
Is this the same as using the clone program above?
No.
I would avoid this method when migrating from a HDD to an SSD.
Why?
Cloning is exactly what it's name implies - an exact copy of your drive down to the block level meaning blocks of data which were marked as deleted on the HDD but not overwritten get cloned to the SSD.
And herein lies the problem. Spinning drives delete files by deleting the pointer to the data (like deleting your address from government records but leaving the structure in tact). SSDs on the other hand goes in and marks the area as "unused" (not just deleting the address, but putting a note on the record that it's unused while sending a working to report back that the building doesn't exist).
When you clone, you will be cloning orphaned data that wasn't marked as unused but will subsequently write to that block.
(IMO) I would use this opportunity to do a clean install of macOS and migrate my data/settings over with Migration Assistant. It will take longer than a simple backup/restore, but you get the opportunity to start with a "clean slate" so to speak which will pay off in the future (you're not copying/restoring hidden issues you backed up)