Termux cannot run fastboot commands while the phone is in Fastboot mode unless you have specific kernel support or are using a secondary device. Standard Android kernels do not allow userspace programs (like Termux) to communicate with the bootloader hardware.
Here is the comprehensive checklist of requirements: unlock bootloader using termux link
Unlock Bootloader of any Device using PC or Android. - GitHub Termux cannot run fastboot commands while the phone
Generic fastboot unlock flow (will wipe data and may display irreversible warnings): unlock bootloader using termux link