I figured out that you can pass variables from Termux to a Tasker task. This example sets Android's volume to a value specified in Termux.

Step 1: Creating the script

volume.sh

#!/data/data/com.termux/files/usr/bin/sh
#am broadcast --user 0 -a net.dinglish.tasker.[task name] -e [variable name] "[value]" > /dev/null
am broadcast --user 0 -a net.dinglish.tasker.volume -e volume "$1" > /dev/null

Step 2: Create a Tasker profile

Screenshot

  1. Create a new profile
  2. Choose "Event"
  3. In the "Select Event Category" dialog choose "System"->"Intent Received"
  4. As Action define net.dinglish.tasker.volume

This profile will now be called whenever it receives the "volume" intent.

Step 3: Create the Task

Screenshot

  1. Tap "New Task" and give it a name
  2. Tap + to add a new Action
  3. Choose "Audio"->"Media Volume"
  4. Under "Level" tap the icon with the crossing arrows to switch to text mode.
  5. Enter %volume as a value
  6. You need to exit Tasker for the changes to take effect.

Step 4: Run the script

You can now run the script. It will send an intent to Tasker. It will put the first argument as new volume, which has to be an integer from 0-15.

./volume.sh 4

This is only a simple example of what you can do with variables. Let me know what you come up with.