Use a command line tool like rmtrashrmtrash (which usually just moves the file(s) to ~/.Trash making sure that the file has a unique name) or a script that uses appscript to call the Finder to do the delete. The latter is slower but adds the ability to use the Put Back option fromn Finder to restore the file easily.
I used trash as it is in in MacPorts and Homebrew and rmtrash is now very old and unmaintained. However on reading the code changes when editing this note I noticed that it changed in 2017 from using the Finder by default to move by default (which is not what I wanted and is a major change). So I will look for another tool.
As noted in the comments it is not a good idea to make rm an alias best to remember to use the trash program you installed directly
But if you wanted to you could do
After installing rmtrash to say /usr/local/bin/rmtrash then you can create an alias for bash
alias rm='rmtrash' You can use \rm to call rm directly and ignore the alias