Is it possible to use the same external hard drive for two different Time Machine backups of two distinct MacBooks?
Is yes, how do you have to set up the external hard drive, using which tools?
Yes. Setup is easy.
tmutilto make a backup.
Now when each Mac tries an hourly backup, if the drive is connected, it will update the backups there. (Make a new interval, expire any old intervals needed). If it’s not connected, you don’t get backups, but do get a warning every 2 weeks to reconnect an absent drive. It’s fine for one Mac to back up to multiple drives as well.
Now, you didn't ask for general advice, so take this with a grain of salt.
So you'd have three drives like if you entered them into service today and the next three days.
Backup A 20200929
Backup B 20200930
Backup C 20201001
Also, last bit of "advice" that wasn't asked for - I put a drive on the shelf as soon as it fills. I don't erase them, just buy another inexpensive drive and then add it to the rotation. They only come off the shelf when I need to rebuild my index of what files are backed up to where with the excellent tool Backup Loupe.