Rotate an object to camera view
Align object to camera
This will give same result as adding an object in camera view, and using ALIGN to VIEW
By default a blender object faces -Y and has Z up. The camera on the other hand looks down -Z with Y up.
Can decompose an objects matrix into its location, rotation and scale, and then recompose.
In this case get the rotation part of the camera matrix world, transformed to -Y forward and Z up then recomposed into the object with its original scale and translation.
import bpy
from mathutils import Vector, Matrix
from bpy import context
from bpy_extras.io_utils import axis_conversion

scene = context.scene
cam_ob = scene.camera
ob = context.object

A = axis_conversion(
        from_forward='Z',
        from_up='-Y',
        to_forward='Y',
        to_up='Z').to_4x4()

loc, rot, scale = cam_ob.matrix_world.decompose()

ob.matrix_world = (
    Matrix.Translation(ob.matrix_world.to_translation()) @
   (rot.to_matrix().to_4x4() @ A) @
    Matrix.Diagonal(ob.matrix_world.to_scale()).to_4x4()
    )