It's not an easy way. Some eMMC have command to write-protect some areas (temporary, or permanently). But these eMMC commands usually are not presented in source code of kernel because there are no practical reasons to use them (unless you are original manufacturer). So, you need to detect what eMMC chip used in your phone, then find good datasheet to find appropriate command (if any). Then write utility to execute this command (and if you write protect a wrong block then there is no way back).
Thus, you need to be a skilled low-end developer to accomplish this task.
If you mean lock like it's done in phones with locked bootloader - then it's completely different story. In this case, write-protect-till-power-off lock used. So, when such phone boots, whole eMMC is available for writing. And then on the very early stage bootloader executes command write-protect-till-power-off, and you can't write anything to bootloader till you turn power off. If you want to accomplish this behaviour then you have to write your own bootloader, which is not simpler than task above. More over, you won't be able to write your own bootloader because it requires to be signed by private master key, which only Samsung lab has