Yes, you can legally represent yourself in court. When you represent yourself, it's known as pro se representation. You don't need to have an attorney when you go to court for child custody. If you choose to represent yourself, you are called a self-represented or pro se litigator.
In New York, New York, Section 18-B of the County Act provides for free legal representation in criminal cases and certain family law matters for individuals who cannot afford an attorney. Parents considering pro se representation should familiarize themselves with the various family law documents that are likely to be found in this process. The New York City Family Court Volunteer Lawyer Program provides brief legal consultations to unrepresented litigants who come to Family Court on matters related to child support, paternity, custody, visitation, and protective orders. While it's sometimes possible for people to represent themselves in family court, you can be doing great harm to yourself and your family if you don't consider at least consulting an attorney before making this decision.
For example, many California counties have a family law aide, a lawyer who provides free assistance.