How to configure SNMPTargetTaddress used for sending (alarms and events) dynamically?

It is just configuration, you can change it via MAAPI or any NB interface based on the YANG model - even via SNMP, but then based on the MIB. Just pay attention to the “weird” way that IP-address+port is represented in MIBs (it’s the same in the YANG model, since it is based on the MIB).