Your command looks correct. sudo shoudn’t be required here.
Your issue might be that you are executing the code to early. TrueNAS also does user synchronization on startup. Your command might be executed before TrueNAS does it’s user sync, in which case your changes would quickly get undone.
and this for when truenas is updated and docker disables itself again:
systemctl enable docker; systemctl start docker
group check
truenas_admin@truenasty[~]$ groups
truenas_admin builtin_administrators
and i cant set it manually anymore:
truenas_admin@truenasty[~]$ sudo usermod -aG docker truenas_admin
[sss_cache] [confdb_init] (0x0010): Unable to open config database [/var/run/sssd-cache/db/config.ldb]
Could not open available domains
truenas_admin@truenasty[~]$ getent group docker
docker:x:999:truenas_admin