I would create a bundle command for this.
You can select the editor as the input to your script, and then replace it with the result of the execution. This command, for example, will accept the selected number and print the "#" symbol so many times.
python -c "print '#' * $TM_SELECTED_TEXT"
Of course, this example does not allow you to specify a symbol, but it gives you an idea of what is possible.