Can I assign a Windows Server license to a virtual machine?

No. A license is assigned to the physical server. Each license will cover one physical processor (old model) or a 2 cores (new model).