#!/bin/bash
s="this_is_my_task() this_is_my____task() ___this_is_my_task() or tHhi_is_my task()"
sed -E ':a; s/\b([a-z][A-Za-z]*)_([a-z]+(_[a-z]+)*\(\))/\1\u\2/; ta'  <<< "$s"
sed -E ':a; s/\b([[:lower:]][[:alpha:]]*)_([[:lower:]]+(_[[:lower:]]+)*\(\))/\1\u\2/; ta'  <<< "$s"