I found the solution. The clue was in question #5382. The following now works.
template = pn.template.FastGridTemplate(title='Modal Test 4')
template.modal.append(pn.Row())
def show_modal(event):
template.modal[0].clear()
template.modal[0].append(f"Randint {random.randint(0, 100)}")
template.open_modal()