Absolutely this is possible - in the UK, Imperial College London have built an aircraft to do exactly this, which they say
"dives like a gannet and launches like a flying fish."
The launch is needed to break surface tension with a small drone, which otherwise makes the take-off difficult.
You could also use a multirotor or helicopter design, and hang a Nansen/Niskin bottle under the aircraft, dip it to the needed depth and close it (e.g. release a messenger weight.) If you know the length of the string and drone altitude you would know the sampling depth. Depending on what you are sampling for, you may need to include sensors to make some in-situ measurements (e.g. temperature.)
This could be executed automatically with most current autopilots - just set the Latitude, Longitude and Altitude needed for the dip. Regulations will vary by jurisdiction and, again, depending on your exact requirements. In the UK for example, doing this under visual line of sight (VLOS) rules should require no further paperwork but for Extended or Beyond VLOS, this would require an Operating Safety Case approved by the CAA. Essentially you just have to think about what could go wrong, and explain how you will keep the risk as low as possible - possible safety mitigations may include:
- Stay over the water - lowers the chance of people under the aircraft and ground hazards
- Stay as low as possible - reduces the risk to aircraft (be aware that rivers are often used by helicopters for navigation, and in many cities some helicopters (e.g. single engine) need to fly over rivers for safety reasons.)
- Publish NOTAM and liaise with local ATC
- Use of an aircraft with redundant flight-critical components
- If the collection site is in EVLOS, manual override available to shore-side observer
- If BVLOS you will need some form of monitoring and recall/abort.
- Approved Electronic Conspicuity device (required for BVLOS in the UK) for visibility to others
- Detect-and-avoid capability
These are non-exhaustive examples - but the CAA are usually quite helpful with their feedback when making such applications.