How can I make API tables mutable, for setting custom properties?

Title says it all. I know the basics of Lua, but am mostly ignorant when it comes to manipulating metatables and other built-in table methods. I’d like to set custom properties on any arbitrary table in the API, but attempting to do so fails with an error like:

myscript.lua:

app.activeSprite.layers[1].foo = "bar"

console:

[string "internal"]:1: stack traceback:
	[string "internal"]:1: in function '__generic_mt_newindex'
	/path/to/myscript.lua:1: in main chunk: Cannot set field foo

Is there a metatable I can edit or something so I can actually set properties (other than on the .data field, which only lets me set strings)?