Yes, in most cases Form N-400 can be filed online. However, if you are applying from outside of the USA, or based on your military service, or if you are applying for a fee waiver or reduced fee, you are not eligible to file your Form N-400 online, only by mail.
In order to file Form N-400, Application for Naturalization, online, first you will have to create an online account on the USCIS official website (https://myaccount.uscis.dhs.gov/). Then you should fill out the form fields.
Furthermore, this online account will allow you to: pay your filing fee online, check the status of your case, receive notifications, respond to requests for evidence, and manage your contact information.