Yes, you can generate DLLs for M files using the MATLAB Coder App.
- Click through all the required steps until you arrive to the "Generate Code" step.
- Click on the drop down arrow besides "Generate"
- Select Built type: Dynamic Link Library
- Click through all the next steps and generate the DLL.
Here is the complete set of instructions for using the MATLAB Coder App: