can’t figure it out if it is possible to set up DNS record to a folder on a server.
Say sub.example.com to point on 1.2.3.4/e2/
Is it possible somehow to point domains directly to folders on a server so I can have different domains hosted on one server within different folders?
It is possible to host multiple domains on one server. It is called Virtual Hosting.
But you are confusing a few concepts. DNS is for converting names to ip addresses. The DNS system knows nothing about the folder structure. That is the responsibility of the webserver. You will configure Virtual Hosts on the web server.
The way this is normally done is to
Add host record (aka, A record) in DNS. For example, coolname.domain.com -> 12.34.56.78.
Configure webserver to read content for coolname.domain.com from folder of your choice.