This should be the correct syntax provided the path to .foobar is /my/dir/.foobar
rclone sync /my/dir remote:/my/remote/dir --exclude "/.foobar/**"
Test using rclone ls
rclone ls /my/dir --exclude "/.foobar/**"
Eg
$ rclone ls .
5 one
0 .potato/two
$ rclone ls . --exclude "/.potato/**"
5 one