you can also escape some characters by preceding them with a \
I have found some cases where you need to escape things twice, once in the AS layer and once in the shell, so you end up with double \
I generally always put my shell commands into a variable first, and then you can see what you are getting using a display dialog like this
set mailCmd to "/usr/libexec/PlistBuddy -c "Add :MailAccounts:2:SentMessagesMailboxName string '$SentItems'" ~/Library/Preferences/com.apple.mail.plist"
display dialog "mailCmd" default answer mailCmd
set mailCmdResult to (do shell script mailCmd)
sometimes it can be helpful to store the result of a do shell script, helpful to detect odd errors
just make sure to comment out the dialog before sharing your script
Why are you using plist buddy instead of defaults write?