If you are working with shared hosting, you probably need to put the full path to your composer executable. So it was in my case. Following the recommendations in this answer SSH Shell commands not found (composer, npm), I managed to run composer from the bash script:
which composer // In remote machine manually
This command shows the path where composer is installed on the remote server. You can also see the path by doing:
echo $PATH // you can surely add it
If composer is not on the $PATH, You can add it, if shared hosting gives you enough privileges, or you can just run the command in your bash script by calling composer with the full path. In my case it was to run:
$/opt/cpanel/composer/bin/composer install