Formation of Ultracompact X-Ray Binaries in Dense Star Clusters