Each snap may have some configuration that is managed by snapd. Current options may be changed and observed via the command line interface with:
$ snap set mysnap myoption=newvalue
$ snap get mysnap myoption
Internally in the snap, when such an option is changed the configuration hook located at meta/hooks/configure (snap/hooks/configure for snapcraft) is run, and once the hook finishes successfully the configuration is considered applied.
These hooks may be written in any language and may use the snapctl tool to change and obtain configuration values via respective set and get commands that do not take a snap name (current snap is assumed).
Changes provided both by the user and the snap are applied all at once after the hook finishes successfully. Any errors (non-zero exit) will prevent the configuration from being applied at all, and will cause the overall change to be cancelled and rolled back. Failure to run within a reasonable time (5 minutes right now) will also cause the hook to be forcefully aborted.