Is it possible to do configuration for containers as a file?

I have used docker for long enough, and when I started LXD, docs and guide I read have suggested only lxc config as the option to configure the container. Is there a way to pre-configure the image with things like binding ports, host mounts and installing dependencies, more like how docker handles with dockerfile.

It is possible, read the Linux Containers - LXD - Advanced guide.

Cloud-init and container configuration is what you want.