Since you can't use an ethernet cable, the Pi 2 will have to have a wifi adapter. If you cannot do that, then you are out of luck -- unless you want to get a USB serial cable and use the Pi's serial port, but in that case, it would make more sense to get a USB ethernet adapter. They are slightly more expensive (say $20 vs $10) but ethernet will be much, much, much better than a UART (serial) link.
Presuming you have a wifi adapter for the Pi, you can then set one or the other up as a wifi hotspot and have the other one connect to it. If you've ever shared your phone's internet access with a non-cellular device, this is exactly the same idea, except no one will have any internet to share.
There are many tutorials online and some Q&As here about setting up the Pi as a wifi hotspot. Note that much of that may focus on sharing internet, which obviously you don't have to be concerned with; you are going to end up with a network of 2.
The adapter must support access point (AP) mode; most of them do. To check:
iw list
This outputs quite a bit. Near the top should be a list, "Supported interface modes", which will include "AP" and/or "AP/VLAN" if the adapter is hotspot capable.
The two fundamental pieces of this are:
hostapd
, which I presume is short for "host access point daemon".
- A DHCP server implementation, e.g., dhcpd (note: not dhcpcd, the extra "c" being for client, whereas you want a server). This is responsible for providing the connected Mac with an IP.
Of course, you may find it easiest to set the Mac up as the hotspot instead.