I assume you mean
page/html/topmenu.phtml in the theme. You can edit the phtml file, as long as you have moved it from the default theme into your own theme.
However, if you want to be more elegant about it and use an observer, see below on a rough idea on how to do that.
If you search your layout files, you'll find that this file is the theme for the
app/code/core/Mage/Page/Block/Html/Topmenu.php and look at the getHtml that is called in the template file. In that function, you'll notice that there is an event thrown
page_block_html_topmenu_gethtml_after. You could create a module that has an observer (google it, lots of resources on create modules/observers) and in this observer it could modify the menu to your liking.