Besides enabling Multi-Editing (as explained by @Alan-Kilborn in his comment), I just had to call the functions directly, just like Scintilla documentation specifies:
SCI_MULTIPLESELECTADDNEXT adds the next occurrence of the main selection within the target to the set of selections as main. If the current selection is empty then select word around caret.
SCI_MULTIPLESELECTADDEACH is similar to SCI_MULTIPLESELECTADDNEXT but adds multiple occurrences instead of just one.
For me, it was unnecessary to call SCI_TARGETWHOLEDOCUMENT, so, for selecting all instances of the word at once, you could just call SCI_MULTIPLESELECTADDNEXT followed by SCI_MULTIPLESELECTADDEACH:
// selects all instances of the selected word (or the word around the caret)
sci_sendmsg 2688 // SCI_MULTIPLESELECTADDNEXT
sci_sendmsg 2689 // SCI_MULTIPLESELECTADDEACH
…which has the same effect of simply calling SCI_MULTIPLESELECTADDEACH twice:
// selects all instances of the selected word (or the word around the caret)
sci_sendmsg 2689 // SCI_MULTIPLESELECTADDEACH
sci_sendmsg 2689 // SCI_MULTIPLESELECTADDEACH
Or, instead of blindly calling it twice, you could check if something is already selected with SCI_GETSELECTIONEMPTY (as used on other comments) and then call it only once:
// selects all instances of the selected word (or the word around the caret)
sci_sendmsg SCI_GETSELECTIONEMPTY
if $(MSG_RESULT) == 1 then
sci_sendmsg 2688 // SCI_MULTIPLESELECTADDNEXT
endif
sci_sendmsg 2689 // SCI_MULTIPLESELECTADDEACH
PS: It would be really nice to have both commands (SCI_MULTIPLESELECTADDNEXT and SCI_MULTIPLESELECTADDEACH) available for hotkeys in “Settings” > “Shortcut Mapper” > “Scintilla commands”.