There are a few problems when it comes to building your own sonar from scratch.
- Get hold of the active element required for sonar: the transducer. Transducer material (usually piezo ceramics) is hard to get in small quantities. Usually they are made to order, and a few hundred dollar for a single batch is pretty common.
- Mechanical design of the transducer. Very little information on this is freely available online. Most companies keep the design process to themselves. And there is some design software available, but that's all commercial as well.
- A watertight housing for transducer and electronics. Not a trivial thing. My experience is that it is very hard to keep water out since it tends to creep through the smallest of holes. Extra complication here is that you will also need some way of connecting the electronics to the outside world.
- The electronics. Although that is not very complicated, it does require some specific components like transformer and tuning coils which are also not as easy to get at the average hobby-electronics store.