I expect you could, but why would you want to? TrueNAS is first and foremost a storage-based operating system. Your proposed use for the system is, well, not storage. If your need is to run VMs and containers, a different OS would likely be better suited for that–I’d suggest Proxmox, personally; there’s even a one-line command[1] to create the HAOS VM. And Cloudflared and MariaDB server can both live inside HAOS.
That’s how I’m running Home Assistant–under Proxmox on a Lenovo mini-PC, using the scripted installation I mentioned. It works great.