Yes and No. Dish soap alone probably won’t be sufficient to kill fungus gnats. You should probably combine the solution with some vinegar and/or sugar. Both substances will attract the fungus gnats towards the dish soap. Once the gnats come into contact with the soap, they will get stuck and likely drown or starve.