You can't use an if statement directly, but you can use ternary operator (aka conditional operator) which behaves the way you want. Here is how it would look:
var testBoolean = true;
var object = {
attributeOne: "attributeOne",
attributeTwo: testBoolean ? "attributeTwo" : "attributeTwoToo"
}