Is it possible to create a script that updates the domain record every time the pppoe connection is established?

Couple of options:
Configure on-up in the PPP profile and then run a script using /tool/fetch to update DNS (if possible).
Use /ip/cloud to get a Mikrotik dns-name (SERIAL_NUMBER..sn.mynetname.net) and CNAME to that from your domain.

The latter is possibly the more reliable (and less work).

Yes,

The PPPoE-Interface can be assigned a “Profile”
In return each Profile can be assigned a “On-Up” and “On-Down” Script.

Something like this:

/int pppoe-client monitor pppoe-client1 once do={
    :if ($status = "connected") do={
    	// here you can use $"local-address" variable
    	// and make changes if actual IP != old IP saved to variables
    }
}

You need write your logic to this script.
if local-address != old_address than use /tool fetch to update IP or execute /ip cloud force-update;