I found your question while trying to figure out the answer myself. Apparently, from my trial and error, it seems to work like this.
When you call the add_item
method for PopupMenu, the third parameter for shortcut keys is generated by making an InputEvent
and passing a value from that to said third parameter.
For example:
# This sets it to "Ctrl + O"
var i := InputEventKey.new()
i.control = true
i.scancode = KEY_O
# It's important to call `get_scancode_with_modifiers()` to convert the value to `int`
$MyPopup.add_item("Open", 0, i.get_scancode_with_modifiers())
Will result in this:

Edit:
I made it a helper function to make things easier to get that int
value.
func get_shortcut(keycode:int,modifier:=[]) -> int:
var i := InputEventKey.new()
i.control = modifier.has("ctrl")
i.shift = modifier.has("shift")
i.alt = modifier.has("alt")
i.scancode = keycode
return i.get_scancode_with_modifiers()
To use it, just do something like get_shortcut(KEY_O,["ctrl"])
= Ctrl+O
For multiple modifiers, just do get_shortcut(KEY_DELETE,["ctrl","shift"])
= Ctrl+Shift+Del.