There is no sample or tutorial... you can do it with nested recordsets and avoid hand coding, or you could use a hand coded IF statement to add the optgroup tag whenever the group changes.
The nested recordset is probably the easiest:
[Recordset for Groups]
<select>
[Repeat Region for Groups]
<optgroup>
[Recordset for Options (filtered with Recordset for Group)]
[Repeat Region for Options]
<option>val</option>
[End Repeat Region for Options]
</optgroup>
[End Repeat Region for Groups