I have an inspiron 15 7000 that came with a 1tb internal sata hard drive. However, there is an m2 slot. If I get a ssd and put it in the m2 slot, can I restore windows to the ssd and boot from that drive?
Yes, although I'm not sure if Dell's factory restore tool would do that. Look at an application such as Macrium Reflect Free. If you use that application, you'd just create their Rescue Media onto either a disc or USB flash drive, then boot your system from that and clone your 1TB drive to your SSD. You'll be able to reduce the size of the cloned partitions on the destination if needed in order to make everything fit onto the SSD. After that completes, reboot your system, make absolutely certain you booted from the SSD (you should be able to tell due to dramatically faster performance), and if so you should be able to wipe your 1TB spinning disk to repurpose it as a data drive. Since the 1TB disk would have been configured as an OS drive, it will have several additional partitions that are normally hidden, so if you want to use its full capacity, I would recommend using something like diskpart's "clean" command to wipe the slate clean, then you can go to Disk Management to re-initialize it, partition it as desired, and format those partitions with the desired file system.
One additional comment: Some M.2 slots support both M.2 SATA and M.2 NVMe/PCIe SSDs, and others only support M.2 SATA. If your system is in the latter category, you wouldn't be able to use the faster NVMe/PCIe SSDs, so be aware of that. If you're not sure, I'm not familiar with the Inspiron 15 7000 line, but someone else might be able to help you if you post the specific model you have. "Inspiron 15 7000" is just a class of systems that has lasted a few generations. Your specific model might be something like Inspiron 7567, for example.