NodeRed has Subflows, but what about YAML code

Subflow in NodeRed is a group of automations, that is very easy to copy and paste and simplify the node.

I wonder, can I do this in YAML file? What code to use?

For instance, I want to trigger notifications in the same way and do not want to repeat the notifications code on many automations.

Create a notification script and pass variables to it. Like the message, title etc…

Repeated YAML can also be condensed using YAML anchors.

Thanks for the reply.
I am not developer. Do you have any examples?

Script variables: https://www.home-assistant.io/integrations/script/#passing-variables-to-scripts

Anchors and others: Solved: Reuse code with YAML Anchors and more