Is Screen Mirroring a feature of the hardware or the software? I have a Samsung Galaxy J7 Max running Android Nougat from Samsung. It seems that it does not support screen mirroring but supports Wifi Direct. 

I want to know that those phone that do support screen mirroring like the Samsung Galaxy A3, do they have special hardware in them, or is it just enabled in that build of the kernel ?

In short, for screen mirroring do you need extra hardware or just need to enable it in the kernel/OS ?
Both.

Just a brief description of how it works:

At the core of this technology is the Wi-Fi Direct™ standard, which allows for point-to-point connections between devices without the use of a router. From there, Miracast adds a vendor-neutral wrapper that originally supported the streaming of up to 1080p video and 5.1 surround sound. It uses this variation of this technology to allow the output of audio and video.


  For the device whose screen you want to mirror, support for Miracast
  requires three things: wireless chipset support, operating
  system support, and driver support. If your device doesn’t meet
  all three of these requirements then you’ll have to buy a Miracast
  adapter and upgrade your operating system.


Users can wirelessly mirror the display of their Miracast-certified® phone, tablet, or PC to any Miracast-capable receiver

Android supported Miracast, in Android 4.2 (Jellybean) and Android 5 (Lollipop).


  On 29 October 2012, Google announced that Android version 4.2+ (from
  updated version of Jelly Bean) are supporting the Miracast wireless
  display standard, and by default have it integrated.


However, Google dropped native Miracast support in Android 6 (Marshmallow) and later, so to mirror the display from a newer Android phone or tablet, you’ll need to do so via Chromecast.

In the case that it is disabled but compatible for a particular Android device, you could edit the build.prop file in the following line:

persist.debug.wfd.enable=1

Using a root explorer navigate to your build.prop file located at 
/system/build.prop

Check if the option is visible in Settings > Display > Cast Screen > Menu > Enable Wireless Display.


  Devices that are Miracast-certified® can communicate with each other,
  regardless of manufacturer.Both devices (the sender and the receiver)
  need to be Miracast certified® for the technology to work.
  However, to stream music and movies to a non-certified device Miracast
  adapters are available that plug into HDMI or USB ports.


The Wi-Fi Alliance has an official list of all Miracast source devices.

There is some evidence however suggesting one can use software based screen mirroring.

Acknowledgements


How to use Miracast to mirror your device's screen wirelessly on your TV—even 4K
5.0+ Lollipop - Enable wireless display with Miracast devices
What Is Miracast? Everything You Need to Know
Miracast