This is definitely possible, but if you want to do it dynamically, you will need to use a filter.
The filter dynamic_sidebar_paramsshould work for you. If you are not familiar with what the filters do, basically the filter allows you to edit the content before it is displayed on the screen or save it to the database. More details here: http://codex.wordpress.org/Plugin_API/Filter_Reference
dynamic_sidebar_params ( print_r)
Array
(
[0] => Array
(
[name] => Primary Widget Area
[id] => primary-widget-area
[description] => The primary widget area
[before_widget] => <li id="search-2" class="widget-container widget_search">
[after_widget] => </li>
[before_title] => <h3 class="widget-title">
[after_title] => </h3>
[widget_id] => search-2
[widget_name] => Search
)
[1] => Array
(
[number] => 2
)
)
, , , $params, . , , , , .
:
function my_edit_widget_func($params) {
$params[0]['before_title'] = '<h3 class="' . $params[0]['widget_name'] . '">' ;
return $params;
}
add_filter('dynamic_sidebar_params', 'my_edit_widget_func');