Found it, just leaving this here to make it easier for others to find answers via google. See:
Specifically, the one thing you need to care about is CFBundleIdentifier in the app's Contents/Info.plist file. Here is a part from a script that may be useful:
# Change Bundle ID so desktop assignation works. Not sure if this will survive updates.
# CFBundleIdentifier must contain only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.) characters.
# (Based on fiddling around there also seems to be a length limit.)
UUID="$(echo $APP | md5sum | awk '{print $1}' | tr [0-9] [A-Z] | cut -c 1-4,29-32)"
plutil -replace CFBundleIdentifier -string "cdi.$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
#plutil -replace CFBundleName -string "$APP" -- "$RUNTIMES/$APP/Contents/Info.plist"
#plutil -replace CFBundleDisplayName -string "$APP" -- "$RUNTIMES/$APP/Contents/Info.plist"
# To check: defaults read ~/Library/Preferences/com.apple.spaces.plist app-bindings
To see this in some context, see my answer to this question: Is there a simple way to have separate dock icons for different Chrome Profiles?