SQL server log shipping - dry-run data modification script on secondary then resume log shipping
On server B, is there any way to instead effectively rollback to a
  previous transaction log (before I tried the script), and then resume
  log shipping?


No there is no way to do this.  You can only bring a log shipped secondary to standby mode.  Which allow read_only operations.  This is done by keeping an undo file.  When you need to restore log files again contents from the undo files are applied first.  

More details about undo file here:

In SQL server, How to see the standby file path when we restore the database in standby mode by Harsh Chawla.

For testing DDL you need to bring database to read_write mode which will undo uncommitted transactions without keeping a log of those pages. There is no way to revert to previous state as you can do in case of standby.