Got it — needed to use a walker function. I used a slightly modified version of the one in this tutorial
The main thing I modified was changing
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url) .'"' : '';
to
$attributes .= ' href="#' . esc_attr( basename(get_permalink()) ) .'"' ;
but I will probably refactor the whole thing