Both LXD and LXC are very happy to work with cgroup2.
systemd will not necessarily automatically detect it so you need to set:
lxc config set <container-name> raw.lxc 'lxc.init.cmd = /sbin/init systemd.unified_cgroup_hierarchy'
However… this won’t be enough because of an AppArmor bug I reported almost two years ago:
Your kernel should report various AppArmor denials for
group2 filesystem. So to get this to work you need to disable AppArmor for unpriv containers. You need the following section in your container’s config:
lxc.init.cmd = /sbin/init systemd.unified_cgroup_hierarchy
lxc.apparmor.profile = unconfined