Getting script name from within the script

Can a script or automation get its own name, similar to $0 in bash?

I send a lot of emails and I like automations (in both bash and HA) to append details at the bottom, including the script that sent the email.

I’m also hoping I can put this in the configuration entry for notify/smtp rather than each individual script?

Yes.

script:
  foo:
    alias: Bar
    sequence:
      - service: notify.notify
        data:
          message: "The script name is {{ state_attr('script.foo', 'friendly_name') }]"

This will send the message “The script name is Bar”.

Nope.

Alternatively, you can use the this variable for self-referencing:

script:
  foo:
    alias: Bar
    sequence:
      - service: notify.notify
        data:
          message: "The script name is {{ this.attributes.friendly_name }}"