The original version of your post referred to "the file in /etc", which is why I said to try
sudo rm /etc/whatever-file-you-mean. To remove a directory with
rm, you need to use
man rm. You really should be at least looking at the man pages of commands that are new to you when you first use them. This could save you the time and hassle of having to ask for help with relatively simple things.
Anyway, to remove a directory you can also use
rmdir -- but it only works on empty directories. To make an educated guess, probably the reason the directory was not removed was because it contains configuration files that have been changed since they were installed; the point of that is so you do not loose config files you may want to use again. Generally re-installing will respect this, I think, but perhaps not in all cases (actually it sounds like that is what happened).
So the solution here is (if hostapd is still installed,
sudo apt remove hostapd first):
sudo rm -r /etc/hostapd
-r, -R, --recursive
remove directories and their contents recursively
This means you could delete the entire root filesystem with
rm -r /, so be careul with it.